select open change scope Open full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

SYSTEM CATALOGS / STATISTICS VIEWS

pg_stat_database

Read PG 18 manual ↗

The pg_stat_database view will contain one row for each database in the cluster, plus one for shared objects, showing database-wide statistics.

Kind
Statistics views
Columns in this snapshot
30
Definition source
English manual

Columns 30

ColumnTypeDescription / reference
datidoidOID of this database, or 0 for objects belonging to a shared relation
datnamenameName of this database, or NULL for shared objects.
numbackendsintegerNumber of backends currently connected to this database, or NULL for shared objects. This is the only column in this view that returns a value reflecting current state; all other columns return the accumulated values since the last reset.
xact_commitbigintNumber of transactions in this database that have been committed
xact_rollbackbigintNumber of transactions in this database that have been rolled back
blks_readbigintNumber of disk blocks read in this database
blks_hitbigintNumber of times disk blocks were found already in the buffer cache, so that a read was not necessary (this only includes hits in the PostgreSQL buffer cache, not the operating system's file system cache)
tup_returnedbigintNumber of live rows fetched by sequential scans and index entries returned by index scans in this database
tup_fetchedbigintNumber of live rows fetched by index scans in this database
tup_insertedbigintNumber of rows inserted by queries in this database
tup_updatedbigintNumber of rows updated by queries in this database
tup_deletedbigintNumber of rows deleted by queries in this database
conflictsbigintNumber of queries canceled due to conflicts with recovery in this database. (Conflicts occur only on standby servers; see pg_stat_database_conflicts for details.)
temp_filesbigintNumber of temporary files created by queries in this database. All temporary files are counted, regardless of why the temporary file was created (e.g., sorting or hashing), and regardless of the log_temp_files setting.
temp_bytesbigintTotal amount of data written to temporary files by queries in this database. All temporary files are counted, regardless of why the temporary file was created, and regardless of the log_temp_files setting.
deadlocksbigintNumber of deadlocks detected in this database
checksum_failuresbigintNumber of data page checksum failures detected in this database (or on a shared object), or NULL if data checksums are disabled.
checksum_last_failuretimestamp with time zoneTime at which the last data page checksum failure was detected in this database (or on a shared object), or NULL if data checksums are disabled.
blk_read_timedouble precisionTime spent reading data file blocks by backends in this database, in milliseconds (if track_io_timing is enabled, otherwise zero)
blk_write_timedouble precisionTime spent writing data file blocks by backends in this database, in milliseconds (if track_io_timing is enabled, otherwise zero)
session_timedouble precisionTime spent by database sessions in this database, in milliseconds (note that statistics are only updated when the state of a session changes, so if sessions have been idle for a long time, this idle time won't be included)
active_timedouble precisionTime spent executing SQL statements in this database, in milliseconds (this corresponds to the states active and fastpath function call in pg_stat_activity)
idle_in_transaction_timedouble precisionTime spent idling while in a transaction in this database, in milliseconds (this corresponds to the states idle in transaction and idle in transaction (aborted) in pg_stat_activity)
sessionsbigintTotal number of sessions established to this database
sessions_abandonedbigintNumber of database sessions to this database that were terminated because connection to the client was lost
sessions_fatalbigintNumber of database sessions to this database that were terminated by fatal errors
sessions_killedbigintNumber of database sessions to this database that were terminated by operator intervention
parallel_workers_to_launchbigintNumber of parallel workers planned to be launched by queries on this database
parallel_workers_launchedbigintNumber of parallel workers launched by queries on this database
stats_resettimestamp with time zoneTime at which these statistics were last reset
Column history across versions
Column9.09.19.29.39.49.59.61011121314151617181920
datid
datname
numbackends
xact_commit
xact_rollback
blks_read
blks_hit
tup_returned
tup_fetched
tup_inserted
tup_updated
tup_deleted
conflicts·
temp_files··
temp_bytes··
deadlocks··
blk_read_time··
blk_write_time··
stats_reset·
checksum_failures·········
checksum_last_failure·········
session_time···········
active_time···········
idle_in_transaction_time···········
sessions···········
sessions_abandoned···········
sessions_fatal···········
sessions_killed···········
parallel_workers_to_launch···············
parallel_workers_launched···············
Version history 12
  1. PG 18 → 19changed
  2. PG 17 → 18changed
  3. PG 14 → 15changed
  4. PG 13 → 14changed
  5. PG 12 → 13changed
  6. PG 11 → 12changed
  7. PG 9.6 → 10changed
  8. PG 9.5 → 9.6changed
  9. PG 9.4 → 9.5changed
  10. PG 9.3 → 9.4changed
  11. PG 9.1 → 9.2changed
  12. PG 9.0 → 9.1changed

Definition snapshot: english-manuals:30526ba339fa924f8330062ba8e… · English manual source