pg_stat_all_indexes

显示每个索引访问统计信息的视图

pg_stat_all_indexes 是一个 统计视图,显示当前数据库中每个索引的访问统计信息。

pg_stat_all_indexesPostgreSQL 7.2 中添加。

按 PostgreSQL 版本定义

pg_stat_all_indexes (PostgreSQL 17)

                   View "pg_catalog.pg_stat_all_indexes"
    Column     |           Type           | Collation | Nullable | Default 
---------------+--------------------------+-----------+----------+---------
 relid         | oid                      |           |          | 
 indexrelid    | oid                      |           |          | 
 schemaname    | name                     |           |          | 
 relname       | name                     |           |          | 
 indexrelname  | name                     |           |          | 
 idx_scan      | bigint                   |           |          | 
 last_idx_scan | timestamp with time zone |           |          | 
 idx_tup_read  | bigint                   |           |          | 
 idx_tup_fetch | bigint                   |           |          |
    

文档: pg_stat_all_indexes

pg_stat_all_indexes (PostgreSQL 16)

                   View "pg_catalog.pg_stat_all_indexes"
    Column     |           Type           | Collation | Nullable | Default 
---------------+--------------------------+-----------+----------+---------
 relid         | oid                      |           |          | 
 indexrelid    | oid                      |           |          | 
 schemaname    | name                     |           |          | 
 relname       | name                     |           |          | 
 indexrelname  | name                     |           |          | 
 idx_scan      | bigint                   |           |          | 
 last_idx_scan | timestamp with time zone |           |          | 
 idx_tup_read  | bigint                   |           |          | 
 idx_tup_fetch | bigint                   |           |          |
    

文档: pg_stat_all_indexes

pg_stat_all_indexes (PostgreSQL 15)

          View "pg_catalog.pg_stat_all_indexes"
    Column     |  Type  | Collation | Nullable | Default 
---------------+--------+-----------+----------+---------
 relid         | oid    |           |          | 
 indexrelid    | oid    |           |          | 
 schemaname    | name   |           |          | 
 relname       | name   |           |          | 
 indexrelname  | name   |           |          | 
 idx_scan      | bigint |           |          | 
 idx_tup_read  | bigint |           |          | 
 idx_tup_fetch | bigint |           |          |
    

文档: pg_stat_all_indexes

pg_stat_all_indexes (PostgreSQL 14)

          View "pg_catalog.pg_stat_all_indexes"
    Column     |  Type  | Collation | Nullable | Default 
---------------+--------+-----------+----------+---------
 relid         | oid    |           |          | 
 indexrelid    | oid    |           |          | 
 schemaname    | name   |           |          | 
 relname       | name   |           |          | 
 indexrelname  | name   |           |          | 
 idx_scan      | bigint |           |          | 
 idx_tup_read  | bigint |           |          | 
 idx_tup_fetch | bigint |           |          |
    

文档: pg_stat_all_indexes

pg_stat_all_indexes (PostgreSQL 13)

          View "pg_catalog.pg_stat_all_indexes"
    Column     |  Type  | Collation | Nullable | Default 
---------------+--------+-----------+----------+---------
 relid         | oid    |           |          | 
 indexrelid    | oid    |           |          | 
 schemaname    | name   |           |          | 
 relname       | name   |           |          | 
 indexrelname  | name   |           |          | 
 idx_scan      | bigint |           |          | 
 idx_tup_read  | bigint |           |          | 
 idx_tup_fetch | bigint |           |          |
    

文档: pg_stat_all_indexes

pg_stat_all_indexes (PostgreSQL 12)

          View "pg_catalog.pg_stat_all_indexes"
    Column     |  Type  | Collation | Nullable | Default 
---------------+--------+-----------+----------+---------
 relid         | oid    |           |          | 
 indexrelid    | oid    |           |          | 
 schemaname    | name   |           |          | 
 relname       | name   |           |          | 
 indexrelname  | name   |           |          | 
 idx_scan      | bigint |           |          | 
 idx_tup_read  | bigint |           |          | 
 idx_tup_fetch | bigint |           |          |
    

文档: pg_stat_all_indexes

pg_stat_all_indexes (PostgreSQL 11)

          View "pg_catalog.pg_stat_all_indexes"
    Column     |  Type  | Collation | Nullable | Default 
---------------+--------+-----------+----------+---------
 relid         | oid    |           |          | 
 indexrelid    | oid    |           |          | 
 schemaname    | name   |           |          | 
 relname       | name   |           |          | 
 indexrelname  | name   |           |          | 
 idx_scan      | bigint |           |          | 
 idx_tup_read  | bigint |           |          | 
 idx_tup_fetch | bigint |           |          |
    

文档: pg_stat_all_indexes

pg_stat_all_indexes (PostgreSQL 10)

          View "pg_catalog.pg_stat_all_indexes"
    Column     |  Type  | Collation | Nullable | Default 
---------------+--------+-----------+----------+---------
 relid         | oid    |           |          | 
 indexrelid    | oid    |           |          | 
 schemaname    | name   |           |          | 
 relname       | name   |           |          | 
 indexrelname  | name   |           |          | 
 idx_scan      | bigint |           |          | 
 idx_tup_read  | bigint |           |          | 
 idx_tup_fetch | bigint |           |          |
    

文档: pg_stat_all_indexes

pg_stat_all_indexes (PostgreSQL 9.6)

View "pg_catalog.pg_stat_all_indexes"
    Column     |  Type  | Modifiers 
---------------+--------+-----------
 relid         | oid    | 
 indexrelid    | oid    | 
 schemaname    | name   | 
 relname       | name   | 
 indexrelname  | name   | 
 idx_scan      | bigint | 
 idx_tup_read  | bigint | 
 idx_tup_fetch | bigint |
    

文档: pg_stat_all_indexes

pg_stat_all_indexes (PostgreSQL 9.5)

View "pg_catalog.pg_stat_all_indexes"
    Column     |  Type  | Modifiers 
---------------+--------+-----------
 relid         | oid    | 
 indexrelid    | oid    | 
 schemaname    | name   | 
 relname       | name   | 
 indexrelname  | name   | 
 idx_scan      | bigint | 
 idx_tup_read  | bigint | 
 idx_tup_fetch | bigint |
    

文档: pg_stat_all_indexes

pg_stat_all_indexes (PostgreSQL 9.4)

View "pg_catalog.pg_stat_all_indexes"
    Column     |  Type  | Modifiers 
---------------+--------+-----------
 relid         | oid    | 
 indexrelid    | oid    | 
 schemaname    | name   | 
 relname       | name   | 
 indexrelname  | name   | 
 idx_scan      | bigint | 
 idx_tup_read  | bigint | 
 idx_tup_fetch | bigint |
    

文档: pg_stat_all_indexes

pg_stat_all_indexes (PostgreSQL 9.3)

View "pg_catalog.pg_stat_all_indexes"
    Column     |  Type  | Modifiers 
---------------+--------+-----------
 relid         | oid    | 
 indexrelid    | oid    | 
 schemaname    | name   | 
 relname       | name   | 
 indexrelname  | name   | 
 idx_scan      | bigint | 
 idx_tup_read  | bigint | 
 idx_tup_fetch | bigint |
    

文档: pg_stat_all_indexes

pg_stat_all_indexes (PostgreSQL 9.2)

View "pg_catalog.pg_stat_all_indexes"
    Column     |  Type  | Modifiers 
---------------+--------+-----------
 relid         | oid    | 
 indexrelid    | oid    | 
 schemaname    | name   | 
 relname       | name   | 
 indexrelname  | name   | 
 idx_scan      | bigint | 
 idx_tup_read  | bigint | 
 idx_tup_fetch | bigint |
    

文档: pg_stat_all_indexes

pg_stat_all_indexes (PostgreSQL 9.1)

View "pg_catalog.pg_stat_all_indexes"
    Column     |  Type  | Modifiers 
---------------+--------+-----------
 relid         | oid    | 
 indexrelid    | oid    | 
 schemaname    | name   | 
 relname       | name   | 
 indexrelname  | name   | 
 idx_scan      | bigint | 
 idx_tup_read  | bigint | 
 idx_tup_fetch | bigint |
    

文档: pg_stat_all_indexes

pg_stat_all_indexes (PostgreSQL 9.0)

View "pg_catalog.pg_stat_all_indexes"
    Column     |  Type  | Modifiers 
---------------+--------+-----------
 relid         | oid    | 
 indexrelid    | oid    | 
 schemaname    | name   | 
 relname       | name   | 
 indexrelname  | name   | 
 idx_scan      | bigint | 
 idx_tup_read  | bigint | 
 idx_tup_fetch | bigint |
    

文档: pg_stat_all_indexes

pg_stat_all_indexes (PostgreSQL 8.4)

View "pg_catalog.pg_stat_all_indexes"
    Column     |  Type  | Modifiers 
---------------+--------+-----------
 relid         | oid    | 
 indexrelid    | oid    | 
 schemaname    | name   | 
 relname       | name   | 
 indexrelname  | name   | 
 idx_scan      | bigint | 
 idx_tup_read  | bigint | 
 idx_tup_fetch | bigint | 
View definition:
 SELECT c.oid AS relid, i.oid AS indexrelid, n.nspname AS schemaname, c.relname, i.relname AS indexrelname, pg_stat_get_numscans(i.oid) AS idx_scan, pg_stat_get_tuples_returned(i.oid) AS idx_tup_read, pg_stat_get_tuples_fetched(i.oid) AS idx_tup_fetch
   FROM pg_class c
   JOIN pg_index x ON c.oid = x.indrelid
   JOIN pg_class i ON i.oid = x.indexrelid
   LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
  WHERE c.relkind = ANY (ARRAY['r'::"char", 't'::"char"]);
    

文档: pg_stat_all_indexes

pg_stat_all_indexes (PostgreSQL 8.3)

View "pg_catalog.pg_stat_all_indexes"
    Column     |  Type  | Modifiers 
---------------+--------+-----------
 relid         | oid    | 
 indexrelid    | oid    | 
 schemaname    | name   | 
 relname       | name   | 
 indexrelname  | name   | 
 idx_scan      | bigint | 
 idx_tup_read  | bigint | 
 idx_tup_fetch | bigint | 
View definition:
 SELECT c.oid AS relid, i.oid AS indexrelid, n.nspname AS schemaname, c.relname, i.relname AS indexrelname, pg_stat_get_numscans(i.oid) AS idx_scan, pg_stat_get_tuples_returned(i.oid) AS idx_tup_read, pg_stat_get_tuples_fetched(i.oid) AS idx_tup_fetch
   FROM pg_class c
   JOIN pg_index x ON c.oid = x.indrelid
   JOIN pg_class i ON i.oid = x.indexrelid
   LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
  WHERE c.relkind = ANY (ARRAY['r'::"char", 't'::"char"]);
    

文档: pg_stat_all_indexes

pg_stat_all_indexes (PostgreSQL 8.2)

View "pg_catalog.pg_stat_all_indexes"
    Column     |  Type  | Modifiers 
---------------+--------+-----------
 relid         | oid    | 
 indexrelid    | oid    | 
 schemaname    | name   | 
 relname       | name   | 
 indexrelname  | name   | 
 idx_scan      | bigint | 
 idx_tup_read  | bigint | 
 idx_tup_fetch | bigint | 
View definition:
 SELECT c.oid AS relid, i.oid AS indexrelid, n.nspname AS schemaname, c.relname, i.relname AS indexrelname, pg_stat_get_numscans(i.oid) AS idx_scan, pg_stat_get_tuples_returned(i.oid) AS idx_tup_read, pg_stat_get_tuples_fetched(i.oid) AS idx_tup_fetch
   FROM pg_class c
   JOIN pg_index x ON c.oid = x.indrelid
   JOIN pg_class i ON i.oid = x.indexrelid
   LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
  WHERE c.relkind = ANY (ARRAY['r'::"char", 't'::"char"]);
    

文档: pg_stat_all_indexes

变更历史

示例

pg_stat_all_indexes 记录的示例内容

postgres=# SELECT * FROM pg_stat_all_indexes WHERE idx_scan > 0 LIMIT 1\gx
-[ RECORD 1 ]-+---------------------------------
relid         | 2619
indexrelid    | 2696
schemaname    | pg_catalog
relname       | pg_statistic
indexrelname  | pg_statistic_relid_att_inh_index
idx_scan      | 56826314
idx_tup_read  | 285116312
idx_tup_fetch | 30899327

分类

统计/监控视图

另请参阅

pg_stat_user_indexespg_stat_sys_indexespg_statio_all_indexespg_statio_sys_indexespg_statio_user_indexespg_stat_all_tables

反馈

提交您对 "pg_stat_all_indexes" 的任何评论、建议或更正 此处