pg_stat_all_tables

A statistics view showing statistics about accesses to each table in the current database

pg_stat_all_tables is a statistics view showing statistics about accesses to each table in the current database.

pg_stat_all_tables was added in PostgreSQL 7.2.

Definition by PostgreSQL version

pg_stat_all_tables (PostgreSQL 13)

                      View "pg_catalog.pg_stat_all_tables"
       Column        |           Type           | Collation | Nullable | Default
---------------------+--------------------------+-----------+----------+---------
 relid               | oid                      |           |          |
 schemaname          | name                     |           |          |
 relname             | name                     |           |          |
 seq_scan            | bigint                   |           |          |
 seq_tup_read        | bigint                   |           |          |
 idx_scan            | bigint                   |           |          |
 idx_tup_fetch       | bigint                   |           |          |
 n_tup_ins           | bigint                   |           |          |
 n_tup_upd           | bigint                   |           |          |
 n_tup_del           | bigint                   |           |          |
 n_tup_hot_upd       | bigint                   |           |          |
 n_live_tup          | bigint                   |           |          |
 n_dead_tup          | bigint                   |           |          |
 n_mod_since_analyze | bigint                   |           |          |
 n_ins_since_vacuum  | bigint                   |           |          |
 last_vacuum         | timestamp with time zone |           |          |
 last_autovacuum     | timestamp with time zone |           |          |
 last_analyze        | timestamp with time zone |           |          |
 last_autoanalyze    | timestamp with time zone |           |          |
 vacuum_count        | bigint                   |           |          |
 autovacuum_count    | bigint                   |           |          |
 analyze_count       | bigint                   |           |          |
 autoanalyze_count   | bigint                   |           |          |
    

Documentation: pg_stat_all_tables

pg_stat_all_tables (PostgreSQL 12)

                      View "pg_catalog.pg_stat_all_tables"
       Column        |           Type           | Collation | Nullable | Default
---------------------+--------------------------+-----------+----------+---------
 relid               | oid                      |           |          |
 schemaname          | name                     |           |          |
 relname             | name                     |           |          |
 seq_scan            | bigint                   |           |          |
 seq_tup_read        | bigint                   |           |          |
 idx_scan            | bigint                   |           |          |
 idx_tup_fetch       | bigint                   |           |          |
 n_tup_ins           | bigint                   |           |          |
 n_tup_upd           | bigint                   |           |          |
 n_tup_del           | bigint                   |           |          |
 n_tup_hot_upd       | bigint                   |           |          |
 n_live_tup          | bigint                   |           |          |
 n_dead_tup          | bigint                   |           |          |
 n_mod_since_analyze | bigint                   |           |          |
 last_vacuum         | timestamp with time zone |           |          |
 last_autovacuum     | timestamp with time zone |           |          |
 last_analyze        | timestamp with time zone |           |          |
 last_autoanalyze    | timestamp with time zone |           |          |
 vacuum_count        | bigint                   |           |          |
 autovacuum_count    | bigint                   |           |          |
 analyze_count       | bigint                   |           |          |
 autoanalyze_count   | bigint                   |           |          |
    

Documentation: pg_stat_all_tables

pg_stat_all_tables (PostgreSQL 11)

                      View "pg_catalog.pg_stat_all_tables"
       Column        |           Type           | Collation | Nullable | Default
---------------------+--------------------------+-----------+----------+---------
 relid               | oid                      |           |          |
 schemaname          | name                     |           |          |
 relname             | name                     |           |          |
 seq_scan            | bigint                   |           |          |
 seq_tup_read        | bigint                   |           |          |
 idx_scan            | bigint                   |           |          |
 idx_tup_fetch       | bigint                   |           |          |
 n_tup_ins           | bigint                   |           |          |
 n_tup_upd           | bigint                   |           |          |
 n_tup_del           | bigint                   |           |          |
 n_tup_hot_upd       | bigint                   |           |          |
 n_live_tup          | bigint                   |           |          |
 n_dead_tup          | bigint                   |           |          |
 n_mod_since_analyze | bigint                   |           |          |
 last_vacuum         | timestamp with time zone |           |          |
 last_autovacuum     | timestamp with time zone |           |          |
 last_analyze        | timestamp with time zone |           |          |
 last_autoanalyze    | timestamp with time zone |           |          |
 vacuum_count        | bigint                   |           |          |
 autovacuum_count    | bigint                   |           |          |
 analyze_count       | bigint                   |           |          |
 autoanalyze_count   | bigint                   |           |          |
    

Documentation: pg_stat_all_tables

pg_stat_all_tables (PostgreSQL 10)

                      View "pg_catalog.pg_stat_all_tables"
       Column        |           Type           | Collation | Nullable | Default
---------------------+--------------------------+-----------+----------+---------
 relid               | oid                      |           |          |
 schemaname          | name                     |           |          |
 relname             | name                     |           |          |
 seq_scan            | bigint                   |           |          |
 seq_tup_read        | bigint                   |           |          |
 idx_scan            | bigint                   |           |          |
 idx_tup_fetch       | bigint                   |           |          |
 n_tup_ins           | bigint                   |           |          |
 n_tup_upd           | bigint                   |           |          |
 n_tup_del           | bigint                   |           |          |
 n_tup_hot_upd       | bigint                   |           |          |
 n_live_tup          | bigint                   |           |          |
 n_dead_tup          | bigint                   |           |          |
 n_mod_since_analyze | bigint                   |           |          |
 last_vacuum         | timestamp with time zone |           |          |
 last_autovacuum     | timestamp with time zone |           |          |
 last_analyze        | timestamp with time zone |           |          |
 last_autoanalyze    | timestamp with time zone |           |          |
 vacuum_count        | bigint                   |           |          |
 autovacuum_count    | bigint                   |           |          |
 analyze_count       | bigint                   |           |          |
 autoanalyze_count   | bigint                   |           |          |
    

Documentation: pg_stat_all_tables

pg_stat_all_tables (PostgreSQL 9.6)

            View "pg_catalog.pg_stat_all_tables"
       Column        |           Type           | Modifiers
---------------------+--------------------------+-----------
 relid               | oid                      |
 schemaname          | name                     |
 relname             | name                     |
 seq_scan            | bigint                   |
 seq_tup_read        | bigint                   |
 idx_scan            | bigint                   |
 idx_tup_fetch       | bigint                   |
 n_tup_ins           | bigint                   |
 n_tup_upd           | bigint                   |
 n_tup_del           | bigint                   |
 n_tup_hot_upd       | bigint                   |
 n_live_tup          | bigint                   |
 n_dead_tup          | bigint                   |
 n_mod_since_analyze | bigint                   |
 last_vacuum         | timestamp with time zone |
 last_autovacuum     | timestamp with time zone |
 last_analyze        | timestamp with time zone |
 last_autoanalyze    | timestamp with time zone |
 vacuum_count        | bigint                   |
 autovacuum_count    | bigint                   |
 analyze_count       | bigint                   |
 autoanalyze_count   | bigint                   |
    

Documentation: pg_stat_all_tables

pg_stat_all_tables (PostgreSQL 9.5)

            View "pg_catalog.pg_stat_all_tables"
       Column        |           Type           | Modifiers
---------------------+--------------------------+-----------
 relid               | oid                      |
 schemaname          | name                     |
 relname             | name                     |
 seq_scan            | bigint                   |
 seq_tup_read        | bigint                   |
 idx_scan            | bigint                   |
 idx_tup_fetch       | bigint                   |
 n_tup_ins           | bigint                   |
 n_tup_upd           | bigint                   |
 n_tup_del           | bigint                   |
 n_tup_hot_upd       | bigint                   |
 n_live_tup          | bigint                   |
 n_dead_tup          | bigint                   |
 n_mod_since_analyze | bigint                   |
 last_vacuum         | timestamp with time zone |
 last_autovacuum     | timestamp with time zone |
 last_analyze        | timestamp with time zone |
 last_autoanalyze    | timestamp with time zone |
 vacuum_count        | bigint                   |
 autovacuum_count    | bigint                   |
 analyze_count       | bigint                   |
 autoanalyze_count   | bigint                   |
    

Documentation: pg_stat_all_tables

pg_stat_all_tables (PostgreSQL 9.4)

            View "pg_catalog.pg_stat_all_tables"
       Column        |           Type           | Modifiers
---------------------+--------------------------+-----------
 relid               | oid                      |
 schemaname          | name                     |
 relname             | name                     |
 seq_scan            | bigint                   |
 seq_tup_read        | bigint                   |
 idx_scan            | bigint                   |
 idx_tup_fetch       | bigint                   |
 n_tup_ins           | bigint                   |
 n_tup_upd           | bigint                   |
 n_tup_del           | bigint                   |
 n_tup_hot_upd       | bigint                   |
 n_live_tup          | bigint                   |
 n_dead_tup          | bigint                   |
 n_mod_since_analyze | bigint                   |
 last_vacuum         | timestamp with time zone |
 last_autovacuum     | timestamp with time zone |
 last_analyze        | timestamp with time zone |
 last_autoanalyze    | timestamp with time zone |
 vacuum_count        | bigint                   |
 autovacuum_count    | bigint                   |
 analyze_count       | bigint                   |
 autoanalyze_count   | bigint                   |
    

Documentation: pg_stat_all_tables

pg_stat_all_tables (PostgreSQL 9.3)

           View "pg_catalog.pg_stat_all_tables"
      Column       |           Type           | Modifiers
-------------------+--------------------------+-----------
 relid             | oid                      |
 schemaname        | name                     |
 relname           | name                     |
 seq_scan          | bigint                   |
 seq_tup_read      | bigint                   |
 idx_scan          | bigint                   |
 idx_tup_fetch     | bigint                   |
 n_tup_ins         | bigint                   |
 n_tup_upd         | bigint                   |
 n_tup_del         | bigint                   |
 n_tup_hot_upd     | bigint                   |
 n_live_tup        | bigint                   |
 n_dead_tup        | bigint                   |
 last_vacuum       | timestamp with time zone |
 last_autovacuum   | timestamp with time zone |
 last_analyze      | timestamp with time zone |
 last_autoanalyze  | timestamp with time zone |
 vacuum_count      | bigint                   |
 autovacuum_count  | bigint                   |
 analyze_count     | bigint                   |
 autoanalyze_count | bigint                   |
    

Documentation: pg_stat_all_tables

pg_stat_all_tables (PostgreSQL 9.2)

           View "pg_catalog.pg_stat_all_tables"
      Column       |           Type           | Modifiers
-------------------+--------------------------+-----------
 relid             | oid                      |
 schemaname        | name                     |
 relname           | name                     |
 seq_scan          | bigint                   |
 seq_tup_read      | bigint                   |
 idx_scan          | bigint                   |
 idx_tup_fetch     | bigint                   |
 n_tup_ins         | bigint                   |
 n_tup_upd         | bigint                   |
 n_tup_del         | bigint                   |
 n_tup_hot_upd     | bigint                   |
 n_live_tup        | bigint                   |
 n_dead_tup        | bigint                   |
 last_vacuum       | timestamp with time zone |
 last_autovacuum   | timestamp with time zone |
 last_analyze      | timestamp with time zone |
 last_autoanalyze  | timestamp with time zone |
 vacuum_count      | bigint                   |
 autovacuum_count  | bigint                   |
 analyze_count     | bigint                   |
 autoanalyze_count | bigint                   |
    

Documentation: pg_stat_all_tables

pg_stat_all_tables (PostgreSQL 9.1)

           View "pg_catalog.pg_stat_all_tables"
      Column       |           Type           | Modifiers
-------------------+--------------------------+-----------
 relid             | oid                      |
 schemaname        | name                     |
 relname           | name                     |
 seq_scan          | bigint                   |
 seq_tup_read      | bigint                   |
 idx_scan          | bigint                   |
 idx_tup_fetch     | bigint                   |
 n_tup_ins         | bigint                   |
 n_tup_upd         | bigint                   |
 n_tup_del         | bigint                   |
 n_tup_hot_upd     | bigint                   |
 n_live_tup        | bigint                   |
 n_dead_tup        | bigint                   |
 last_vacuum       | timestamp with time zone |
 last_autovacuum   | timestamp with time zone |
 last_analyze      | timestamp with time zone |
 last_autoanalyze  | timestamp with time zone |
 vacuum_count      | bigint                   |
 autovacuum_count  | bigint                   |
 analyze_count     | bigint                   |
 autoanalyze_count | bigint                   |
    

Documentation: pg_stat_all_tables

pg_stat_all_tables (PostgreSQL 9.0)

          View "pg_catalog.pg_stat_all_tables"
      Column      |           Type           | Modifiers
------------------+--------------------------+-----------
 relid            | oid                      |
 schemaname       | name                     |
 relname          | name                     |
 seq_scan         | bigint                   |
 seq_tup_read     | bigint                   |
 idx_scan         | bigint                   |
 idx_tup_fetch    | bigint                   |
 n_tup_ins        | bigint                   |
 n_tup_upd        | bigint                   |
 n_tup_del        | bigint                   |
 n_tup_hot_upd    | bigint                   |
 n_live_tup       | bigint                   |
 n_dead_tup       | bigint                   |
 last_vacuum      | timestamp with time zone |
 last_autovacuum  | timestamp with time zone |
 last_analyze     | timestamp with time zone |
 last_autoanalyze | timestamp with time zone |
    

Documentation: pg_stat_all_tables

pg_stat_all_tables (PostgreSQL 8.4)

          View "pg_catalog.pg_stat_all_tables"
      Column      |           Type           | Modifiers
------------------+--------------------------+-----------
 relid            | oid                      |
 schemaname       | name                     |
 relname          | name                     |
 seq_scan         | bigint                   |
 seq_tup_read     | bigint                   |
 idx_scan         | bigint                   |
 idx_tup_fetch    | bigint                   |
 n_tup_ins        | bigint                   |
 n_tup_upd        | bigint                   |
 n_tup_del        | bigint                   |
 n_tup_hot_upd    | bigint                   |
 n_live_tup       | bigint                   |
 n_dead_tup       | bigint                   |
 last_vacuum      | timestamp with time zone |
 last_autovacuum  | timestamp with time zone |
 last_analyze     | timestamp with time zone |
 last_autoanalyze | timestamp with time zone |
View definition:
 SELECT c.oid AS relid, n.nspname AS schemaname, c.relname, pg_stat_get_numscans(c.oid) AS seq_scan, pg_stat_get_tuples_returned(c.oid) AS seq_tup_read, sum(pg_stat_get_numscans(i.indexrelid))::bigint AS idx_scan, sum(pg_stat_get_tuples_fetched(i.indexrelid))::bigint + pg_stat_get_tuples_fetched(c.oid) AS idx_tup_fetch, pg_stat_get_tuples_inserted(c.oid) AS n_tup_ins, pg_stat_get_tuples_updated(c.oid) AS n_tup_upd, pg_stat_get_tuples_deleted(c.oid) AS n_tup_del, pg_stat_get_tuples_hot_updated(c.oid) AS n_tup_hot_upd, pg_stat_get_live_tuples(c.oid) AS n_live_tup, pg_stat_get_dead_tuples(c.oid) AS n_dead_tup, pg_stat_get_last_vacuum_time(c.oid) AS last_vacuum, pg_stat_get_last_autovacuum_time(c.oid) AS last_autovacuum, pg_stat_get_last_analyze_time(c.oid) AS last_analyze, pg_stat_get_last_autoanalyze_time(c.oid) AS last_autoanalyze
   FROM pg_class c
   LEFT JOIN pg_index i ON c.oid = i.indrelid
   LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
  WHERE c.relkind = ANY (ARRAY['r'::"char", 't'::"char"])
  GROUP BY c.oid, n.nspname, c.relname;
    

Documentation: pg_stat_all_tables

pg_stat_all_tables (PostgreSQL 8.3)

          View "pg_catalog.pg_stat_all_tables"
      Column      |           Type           | Modifiers
------------------+--------------------------+-----------
 relid            | oid                      |
 schemaname       | name                     |
 relname          | name                     |
 seq_scan         | bigint                   |
 seq_tup_read     | bigint                   |
 idx_scan         | bigint                   |
 idx_tup_fetch    | bigint                   |
 n_tup_ins        | bigint                   |
 n_tup_upd        | bigint                   |
 n_tup_del        | bigint                   |
 n_tup_hot_upd    | bigint                   |
 n_live_tup       | bigint                   |
 n_dead_tup       | bigint                   |
 last_vacuum      | timestamp with time zone |
 last_autovacuum  | timestamp with time zone |
 last_analyze     | timestamp with time zone |
 last_autoanalyze | timestamp with time zone |
View definition:
 SELECT c.oid AS relid, n.nspname AS schemaname, c.relname, pg_stat_get_numscans(c.oid) AS seq_scan, pg_stat_get_tuples_returned(c.oid) AS seq_tup_read, sum(pg_stat_get_numscans(i.indexrelid))::bigint AS idx_scan, sum(pg_stat_get_tuples_fetched(i.indexrelid))::bigint + pg_stat_get_tuples_fetched(c.oid) AS idx_tup_fetch, pg_stat_get_tuples_inserted(c.oid) AS n_tup_ins, pg_stat_get_tuples_updated(c.oid) AS n_tup_upd, pg_stat_get_tuples_deleted(c.oid) AS n_tup_del, pg_stat_get_tuples_hot_updated(c.oid) AS n_tup_hot_upd, pg_stat_get_live_tuples(c.oid) AS n_live_tup, pg_stat_get_dead_tuples(c.oid) AS n_dead_tup, pg_stat_get_last_vacuum_time(c.oid) AS last_vacuum, pg_stat_get_last_autovacuum_time(c.oid) AS last_autovacuum, pg_stat_get_last_analyze_time(c.oid) AS last_analyze, pg_stat_get_last_autoanalyze_time(c.oid) AS last_autoanalyze
   FROM pg_class c
   LEFT JOIN pg_index i ON c.oid = i.indrelid
   LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
  WHERE c.relkind = ANY (ARRAY['r'::"char", 't'::"char"])
  GROUP BY c.oid, n.nspname, c.relname;
    

Documentation: pg_stat_all_tables

pg_stat_all_tables (PostgreSQL 8.2)

          View "pg_catalog.pg_stat_all_tables"
      Column      |           Type           | Modifiers
------------------+--------------------------+-----------
 relid            | oid                      |
 schemaname       | name                     |
 relname          | name                     |
 seq_scan         | bigint                   |
 seq_tup_read     | bigint                   |
 idx_scan         | bigint                   |
 idx_tup_fetch    | bigint                   |
 n_tup_ins        | bigint                   |
 n_tup_upd        | bigint                   |
 n_tup_del        | bigint                   |
 last_vacuum      | timestamp with time zone |
 last_autovacuum  | timestamp with time zone |
 last_analyze     | timestamp with time zone |
 last_autoanalyze | timestamp with time zone |
View definition:
 SELECT c.oid AS relid, n.nspname AS schemaname, c.relname, pg_stat_get_numscans(c.oid) AS seq_scan, pg_stat_get_tuples_returned(c.oid) AS seq_tup_read, sum(pg_stat_get_numscans(i.indexrelid))::bigint AS idx_scan, sum(pg_stat_get_tuples_fetched(i.indexrelid))::bigint + pg_stat_get_tuples_fetched(c.oid) AS idx_tup_fetch, pg_stat_get_tuples_inserted(c.oid) AS n_tup_ins, pg_stat_get_tuples_updated(c.oid) AS n_tup_upd, pg_stat_get_tuples_deleted(c.oid) AS n_tup_del, pg_stat_get_last_vacuum_time(c.oid) AS last_vacuum, pg_stat_get_last_autovacuum_time(c.oid) AS last_autovacuum, pg_stat_get_last_analyze_time(c.oid) AS last_analyze, pg_stat_get_last_autoanalyze_time(c.oid) AS last_autoanalyze
   FROM pg_class c
   LEFT JOIN pg_index i ON c.oid = i.indrelid
   LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
  WHERE c.relkind = ANY (ARRAY['r'::"char", 't'::"char"])
  GROUP BY c.oid, n.nspname, c.relname;
    

Documentation: pg_stat_all_tables

Change history

Note: any changes prior to PostgreSQL 8.3 are not noted here.

Categories

Statistics / monitoring view

See also

pg_stat_user_tables, pg_stat_sys_tables, pg_stat_xact_all_tables, pg_stat_xact_sys_tables, pg_stat_xact_user_tables, pg_statio_all_tables, pg_statio_sys_tables, pg_statio_user_tables