Updated on 2024-05-07 GMT+08:00

PG_STAT_DATABASE

PG_STAT_DATABASE displays statistics about each database in the cluster.

Table 1 PG_STAT_DATABASE columns

Name

Type

Description

datid

oid

OID of a database

datname

name

Database name.

numbackends

integer

Number of backends currently connected to this database. This is the only column in the view that returns the current status value. Other columns return the accumulated value since the last reset.

xact_commit

bigint

Number of transactions in this database that have been committed.

xact_rollback

bigint

Number of transactions in this database that have been rolled back.

blks_read

bigint

Number of disk blocks read in this database.

blks_hit

bigint

Number of times that disk blocks have been found in the buffer cache and therefore the disk blocks do not need to be read (only those found in the buffer cache are counted, excluding those found in the file system cache of the OS).

tup_returned

bigint

Number of rows returned by queries in this database

tup_fetched

bigint

Number of rows fetched by queries in this database

tup_inserted

bigint

Number of rows inserted by queries in this database

tup_updated

bigint

Number of rows updated by queries in this database

tup_deleted

bigint

Number of rows deleted by queries in this database

conflicts

bigint

Number of queries canceled due to database recovery conflicts (conflicts occurring only on the standby node). For details, see PG_STAT_DATABASE_CONFLICTS.

temp_files

bigint

Number of all temporary files created by queries in this database, regardless of why the temporary files are created (such as sorting or hashing) or how the log_temp_files parameter is set.

temp_bytes

bigint

Total amount of data written to all temporary files by queries in this database, regardless of why the temporary files are created or how the log_temp_files parameter is set.

deadlocks

bigint

Number of deadlocks detected in the database.

blk_read_time

double precision

Time spent reading data file blocks by backends in this database, in milliseconds

blk_write_time

double precision

Time spent reading data file blocks by backends in this database, in milliseconds

stats_reset

timestamp with time zone

Time when the current status statistics are reset.