跳转到主要内容
← 目录图谱 / pg_stat_database

STATISTICS VIEW · 统计视图

pg_stat_database

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

首次收录 PG 9.0最近收录 PG 19当前字段 30

已与 PostgreSQL 18.6 实例逐字段核对 · 原始实测记录 ↗

字段结构 PostgreSQL 18

pg_stat_database
字段 / COLUMN类型 / TYPE说明 / DESCRIPTION
datid oid OID of this database, or 0 for objects belonging to a shared relation
datname name Name of this database, or NULL for shared objects.
numbackends integer Number 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_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 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_returned bigint Number of live rows fetched by sequential scans and index entries returned by index scans in this database
tup_fetched bigint Number of live rows fetched by index scans 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 conflicts with recovery in this database. (Conflicts occur only on standby servers; see pg_stat_database_conflicts for details.)
temp_files bigint Number 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_bytes bigint Total 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.
deadlocks bigint Number of deadlocks detected in this database
checksum_failures bigint Number of data page checksum failures detected in this database (or on a shared object), or NULL if data checksums are disabled.
checksum_last_failure timestamp with time zone Time 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_time double precision Time spent reading data file blocks by backends in this database, in milliseconds (if track_io_timing is enabled, otherwise zero)
blk_write_time double precision Time spent writing data file blocks by backends in this database, in milliseconds (if track_io_timing is enabled, otherwise zero)
session_time double precision Time 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_time double precision Time 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_time double precision Time 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)
sessions bigint Total number of sessions established to this database
sessions_abandoned bigint Number of database sessions to this database that were terminated because connection to the client was lost
sessions_fatal bigint Number of database sessions to this database that were terminated by fatal errors
sessions_killed bigint Number of database sessions to this database that were terminated by operator intervention
parallel_workers_to_launch bigint Number of parallel workers planned to be launched by queries on this database
parallel_workers_launched bigint Number of parallel workers launched by queries on this database
stats_reset timestamp with time zone Time at which these statistics were last reset

标记“隐式列”的字段不包含在 SELECT * 中;部分早期统计视图由同版本源码补全,额外来源会显示在字段说明中。

字段演化矩阵

悬停查看字段类型
存在新增 / 类型或属性变化移除
字段 / COLUMN9.09.19.29.39.49.59.610111213141516171819
datid
datname
numbackends
xact_commit
xact_rollback
blks_read
blks_hit
tup_returned
tup_fetched
tup_inserted
tup_updated
tup_deleted
conflicts
stats_reset
temp_files
temp_bytes
deadlocks
blk_read_time
blk_write_time
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

9.0 是收录基线;基线中已存在的字段不标记为新增。矩阵按字段名称对齐,重命名显示为旧字段移除与新字段新增。

演化时间线

相邻大版本的变化

PostgreSQL 19 ← 18

2 处字段说明更新

PostgreSQL 18 ← 17

+ parallel_workers_to_launch+ parallel_workers_launched2 处字段说明更新

PostgreSQL 15 ← 14

2 处字段说明更新

PostgreSQL 14 ← 13

+ session_time+ active_time+ idle_in_transaction_time+ sessions+ sessions_abandoned+ sessions_fatal+ sessions_killed

PostgreSQL 13 ← 12

4 处字段说明更新目录说明更新

PostgreSQL 12 ← 11

+ checksum_failures+ checksum_last_failure3 处字段说明更新目录说明更新

PostgreSQL 10 ← 9.6

目录说明更新

PostgreSQL 9.6 ← 9.5

目录说明更新

PostgreSQL 9.5 ← 9.4

目录说明更新

PostgreSQL 9.4 ← 9.3

目录说明更新

PostgreSQL 9.2 ← 9.1

+ temp_files+ temp_bytes+ deadlocks+ blk_read_time+ blk_write_time目录说明更新

PostgreSQL 9.1 ← 9.0

+ conflicts+ stats_reset目录说明更新

比较任意两个版本

选择两个版本,查看字段的新增、移除与类型变化。交互比较需要 JavaScript;演化时间线可直接阅读。