PostgreSQL查看索引的使用情况

 

查看某个表的索引使用情况

select relname, indexrelname, idx_scan, idx_tup_read, idx_tup_fetch from pg_stat_user_indexes where relname = table_name order by idx_scan asc, idx_tup_read asc, idx_tup_fetch asc;

查看所有表的索引的使用情况

select relname, indexrelname, idx_scan, idx_tup_read, idx_tup_fetch from pg_stat_user_indexes order by idx_scan asc, idx_tup_read asc, idx_tup_fetch asc;

存放索引详细信息的表

data_name=# \d+ pg_stat_user_indexes;
           View "pg_catalog.pg_stat_user_indexes"
    Column     |  Type  | Modifiers | Storage | Description 
---------------+--------+-----------+---------+-------------
 relid         | oid |           | plain | 
 indexrelid    | oid |           | plain | 
 schemaname    | name |           | plain | 
 relname       | name |           | plain | 
 indexrelname  | name |           | plain | 
 idx_scan      | bigint |           | plain | 
 idx_tup_read  | bigint |           | plain | 
 idx_tup_fetch | bigint |           | plain | 
View definition:
 SELECT pg_stat_all_indexes.relid,
    pg_stat_all_indexes.indexrelid,
    pg_stat_all_indexes.schemaname,
    pg_stat_all_indexes.relname,
    pg_stat_all_indexes.indexrelname,
    pg_stat_all_indexes.idx_scan,
    pg_stat_all_indexes.idx_tup_read,
    pg_stat_all_indexes.idx_tup_fetch
   FROM pg_stat_all_indexes
  WHERE (pg_stat_all_indexes.schemaname <> ALL (ARRAY['pg_catalog'::name, 'information_schema'::name])) AND pg_stat_all_indexes.schemaname !~ '^pg_toast'::text;

 

 

 

 

pg_stat_user_indexs 表的详细解释参考官方文档:

https://www.postgresql.org/docs/9.2/monitoring-stats.html

 

转载于:https://www.cnblogs.com/ryanzheng/p/9926653.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值