Inspecting databases

Once you have inspected the active database connections, you can dig deeper and inspect database-level statistics. pg_stat_database will return one line per database inside your PostgreSQL instance.

This is what you will find there:

test=# \d pg_stat_database                        View "pg_catalog.pg_stat_database"        Column         |           Type           | Collation | Nullable | Default -----------------------+--------------------------+-----------+----------+--------- datid                 | oid                      |           |          |  datname               | name                     |           |          |  numbackends           | integer                  |           |          |  xact_commit           | bigint                   |           |          |  xact_rollback         | bigint                   |           |          |  blks_read             | bigint                   |           |          |  blks_hit              | bigint                   |           |          |  tup_returned          | bigint                   |           |          |  tup_fetched           | bigint                   |           |          |  tup_inserted          | bigint                   |           |          |  tup_updated           | bigint                   |           |          |  tup_deleted ...

Get Mastering PostgreSQL 12 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.