索引相关操作
最近更新时间: 2024-10-17 17:10:00
- 建立索引。
postgres=# create unique index tbase_id_uidx on tbase(id);
CREATE INDEX
postgres=# create index tbase_mc_idx on tbase(mc);
CREATE INDEX
postgres=#
- \di查看索引列表。
postgres=# \di
List of relations
Schema | Name | Type | Owner | Table
--------+---------------+-------+-------+-------
public | tbase_id_uidx | index | tbase | tbase
public | tbase_mc_idx | index | tbase | tbase
(2 rows)
- \di+查看索引列表详细信息(包含注释),占用空间大小--只能在dn上面查看索引大小。
postgres=# \di+
List of relations
Schema | Name | Type | Owner | Table | Size | Description
--------+---------------+-------+-------+-------+------------+---------------
public | tbase_id_uidx | index | tbase | tbase | 8192 bytes | tbase唯一索引
public | tbase_mc_idx | index | tbase | tbase | 8192 bytes |
(2 rows)
- \di+显示某个模式下的所有索引--只能在dn上面查看索引大小。
postgres=# \di+ public.*
List of relations
Schema | Name | Type | Owner | Table | Size | Description
--------+---------------+-------+-------+-------+------------+---------------
public | tbase_id_uidx | index | tbase | tbase | 8192 bytes | tbase唯一索引
public | tbase_mc_idx | index | tbase | tbase | 8192 bytes |
(2 rows)
- \di+索引名显示某个索引的详细信息--只能在dn上面查看索引大小。
postgres=# \di+ public.tbase_id_uidx
List of relations
Schema | Name | Type | Owner | Table | Size | Description
--------+---------------+-------+-------+-------+------------+---------------
public | tbase_id_uidx | index | tbase | tbase | 8192 bytes | tbase唯一索引
(1 row)
- \di+通配符列出适配的索引--只能在dn上面查看索引大小。
postgres=# \di+ *idx
List of relations
Schema | Name | Type | Owner | Table | Size | Description
--------+-------------------+-------+-------+------------+------------+---------------
pgxc |order_main_id_idx | index | tbase |order_main | 8192 bytes |
public | tbase_id_uidx | index | tbase | tbase | 8192 bytes | tbase唯一索引
public | tbase_mc_idx | index | tbase | tbase | 8192 bytes |
(3 rows)
postgres=# \di+ *uidx--#只能在dn上面查看索引大小
List of relations
Schema | Name | Type | Owner | Table | Size | Description
--------+---------------+-------+-------+-------+------------+---------------
public | tbase_id_uidx | index | tbase | tbase | 8192 bytes | tbase唯一索引
(1 row)