STATISTICS VIEW统计视图
pg_stat_database
每个数据库一行,显示数据库范围的统计信息。有关详细信息,请参阅pg_stat_database。
统计视图 引入 9.0(基线) 现存至 20 devel 5 次结构变更
版本轨迹
相对 PostgreSQL 17:新增 2 个字段,描述更新 2 处。
pg_stat_database视图将包含一行用于集簇中的每个数据库,加一行用于共享对象,显示数据库范围的统计信息。
字段
PostgreSQL 18 的 30 个字段,按定义顺序排列。说明默认用本站手册的译文,没有译文的按英文原文显示。
| 字段 | 类型 | 说明 |
|---|---|---|
datid
|
oid
|
该数据库的OID,属于共享关系的对象为0 |
datname
|
name
|
这个数据库的名称,或者共享对象为NULL。 |
numbackends
|
integer
|
当前连接到此数据库的后端数,对于共享对象则为NULL。 这是该视图中唯一返回反映当前状态的值的列;所有其他列返回自上次重置以来累积的值。 |
xact_commit
|
bigint
|
此数据库中已提交的事务数 |
xact_rollback
|
bigint
|
该数据库中已回滚的事务数 |
blks_read
|
bigint
|
在该数据库中读取的磁盘块数 |
blks_hit
|
bigint
|
在缓冲区缓存中发现磁盘块、因而无需读取的次数(这里只统计 PostgreSQL 缓冲区缓存中的命中,不包括操作系统文件系统缓存中的命中) |
tup_returned
|
bigint
|
由顺序扫描获取的活动行数和由索引扫描返回的索引条目数 |
tup_fetched
|
bigint
|
该数据库中由索引扫描检索的活动行数 |
tup_inserted
|
bigint
|
查询在该数据库中插入的行数 |
tup_updated
|
bigint
|
这个数据库中查询更新的行数 |
tup_deleted
|
bigint
|
这个数据库中被查询删除的行数 |
conflicts
|
bigint
|
由于与此数据库中的恢复冲突而被取消的查询数。(冲突只会发生在备库上;请参阅pg_stat_database_conflicts。) |
temp_files
|
bigint
|
这个数据库中查询创建的临时文件的数量。所有临时文件都将被计数,而不顾及临时文件为什么被创建(例如,排序或散列),也不考虑log_temp_files设置。 |
temp_bytes
|
bigint
|
这个数据库中的查询写入临时文件的数据总量。所有临时文件都将被计数,而不考虑临时文件为什么被创建,也不考虑log_temp_files设置。 |
deadlocks
|
bigint
|
在此数据库中检测到的死锁数 |
checksum_failures
|
bigint
|
在此数据库(或共享对象)中检测到的数据页校验码失败数,如果没有启用数据校验码则为NULL。 |
checksum_last_failure
|
timestamp with time zone
|
在此数据库(或共享对象)中检测到最后一个数据页校验码失败的时间,如果没有启用数据校验码则为NULL。 |
blk_read_time
|
double precision
|
在这个数据库中通过后端读取数据文件块所花费的时间,以毫秒为单位(如果启用了track_io_timing,否则为零) |
blk_write_time
|
double precision
|
在这个数据库中通过后端写数据文件块所花费的时间,以毫秒为单位(如果启用了track_io_timing,否则为零) |
session_time
|
double precision
|
此数据库中数据库会话所消耗的时间,以毫秒计(注意统计信息仅在会话状态发生变化时更新,因此如果会话空闲很长时间,则不包括此空闲时间) |
active_time
|
double precision
|
此数据库中执行SQL语句所消耗的时间,以毫秒计(这对应于 pg_stat_activity中的 active 和 fastpath function call 状态) |
idle_in_transaction_time
|
double precision
|
此数据库中事务空闲所消耗的时间,以毫秒计(这对应于 pg_stat_activity中的 idle in transaction 和 idle in transaction (aborted) 状态) |
sessions
|
bigint
|
此数据库建立的会话总数 |
sessions_abandoned
|
bigint
|
此数据库因为到客户端的连接丢失而被终止的数据库会话数 |
sessions_fatal
|
bigint
|
此数据库因为致命错误而被终止的数据库会话数 |
sessions_killed
|
bigint
|
此数据库因为操作者介入而被终止的数据库会话数 |
parallel_workers_to_launch
新
|
bigint
|
计划由该数据库上的查询启动的并行工作进程数 |
parallel_workers_launched
新
|
bigint
|
由该数据库上的查询启动的并行工作进程数 |
stats_reset
|
timestamp with time zone
|
这些统计数据最后一次重置的时间 |
演化历史
相邻两个大版本之间的差异,新的在前。版本号链到该版的字段表。
-
PostgreSQL 19 ← 18 仅描述更新
2 处描述更新
checksum_failuresNumber of data page checksum failures detected in this database (or on a shared object), or NULL if data checksums are disabled. Number of data page checksum failures detected in this database (or on a shared object). Detected failures are not reset if the data_checksums setting changes. Clusters which are initialized without data checksums will show this as 0. In PostgreSQL version 18 and earlier, this was set to NULL for clusters with data checksums disabled.checksum_last_failureTime 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. Time at which the last data page checksum failure was detected in this database (or on a shared object). Last failure is reported regardless of the data_checksums setting.
-
PostgreSQL 18 ← 17 结构变更
parallel_workers_to_launchparallel_workers_launched2 处描述更新
checksum_failuresNumber of data page checksum failures detected in this database (or on a shared object), or NULL if data checksums are not enabled. Number of data page checksum failures detected in this database (or on a shared object), or NULL if data checksums are disabled.checksum_last_failureTime at which the last data page checksum failure was detected in this database (or on a shared object), or NULL if data checksums are not enabled. 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.
-
PostgreSQL 15 ← 14 仅描述更新
2 处描述更新
tup_fetchedNumber of rows fetched by queries in this database Number of live rows fetched by index scans in this databasetup_returnedNumber of rows returned by queries in this database Number of live rows fetched by sequential scans and index entries returned by index scans in this database
-
PostgreSQL 14 ← 13 结构变更
session_timeactive_timeidle_in_transaction_timesessionssessions_abandonedsessions_fatalsessions_killed -
PostgreSQL 13 ← 12 仅描述更新
关系说明更新
4 处描述更新
blk_read_timeTime spent reading data file blocks by backends in this database, in milliseconds Time spent reading data file blocks by backends in this database, in milliseconds (if track_io_timing is enabled, otherwise zero)blk_write_timeTime spent writing data file blocks by backends in this database, in milliseconds Time spent writing data file blocks by backends in this database, in milliseconds (if track_io_timing is enabled, otherwise zero)datnameName of this database, or NULL for the shared objects. Name of this database, or NULL for shared objects.numbackendsNumber of backends currently connected to this database, or NULL for the 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. 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.
-
PostgreSQL 12 ← 11 结构变更
checksum_failureschecksum_last_failure关系说明更新3 处描述更新
datidOID of a database OID of this database, or 0 for objects belonging to a shared relationdatnameName of this database Name of this database, or NULL for the shared objects.numbackendsNumber of backends currently connected to this database. 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. Number of backends currently connected to this database, or NULL for the 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.
-
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_filestemp_bytesdeadlocksblk_read_timeblk_write_time关系说明更新 -
PostgreSQL 9.1 ← 9.0 结构变更
conflictsstats_reset关系说明更新
字段矩阵
每个字段在 18 个收录版本里的存在情况;方格指向该版的字段表。「有变」指类型、可空、隐式或数组维数与上一版不同。
存在 有变 已移除 不存在
| 字段 | 9.0 | 9.1 | 9.2 | 9.3 | 9.4 | 9.5 | 9.6 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
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 |
不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 不存在 | 存在 | 存在 | 存在 |
同类关系
| 关系 | 引入 | 字段 | 版本变动 | 最近变更 |
|---|---|---|---|---|
pg_stat_activity |
9.0基线 | 22 | 147 次 | |
| 每个服务器进程一行,显示与该进程当前活动相关的信息,例如状态和当前查询。有关详细信息,请参阅pg_stat_activity。 | 现存 | |||
pg_stat_all_indexes |
9.0基线 | 10 | 192 次 | |
| 当前数据库中的每个索引一行,显示有关访问该特定索引的统计信息。有关详细信息,请参阅pg_stat_all_indexes。 | 现存 | |||
pg_stat_all_tables |
9.0基线 | 31 | 196 次 | |
| 当前数据库中每个表一行,显示有关访问指定表的统计信息。详见 pg_stat_all_tables。 | 现存 | |||
pg_stat_archiver |
9.4 | 7 | — | |
| 只有一行,显示有关 WAL 归档进程活动的信息。有关详细信息,请参阅pg_stat_archiver。 | 现存 | |||
pg_stat_autovacuum_scores |
19 | 12 | — | |
| 当前数据库中的每个表一行,显示该表当前的自动清理评分。有关详细信息,请参阅pg_stat_autovacuum_scores。 | 现存 | |||
pg_stat_bgwriter |
9.0基线 | 4 | 173 次 | |
| 只有一行,显示有关后台写入器活动的信息。有关详细信息,请参阅pg_stat_bgwriter。 | 现存 | |||
pg_stat_checkpointer |
17 | 11 | 181 次 | |
| 只有一行,显示有关检查点进程活动的信息。有关详细信息,请参阅pg_stat_checkpointer。 | 现存 | |||
pg_stat_database |
9.0基线 | 30 | 185 次 | |
| 每个数据库一行,显示数据库范围的统计信息。有关详细信息,请参阅pg_stat_database。 | 现存 | |||
pg_stat_database_conflicts |
9.1 | 9 | 192 次 | |
| 每个数据库一行,显示数据库范围内因备库上的恢复冲突而导致查询被取消的统计信息。有关详细信息,请参阅pg_stat_database_conflicts。 | 现存 | |||
pg_stat_gssapi |
12 | 5 | 161 次 | |
| 每个连接(常规连接和复制连接)一行,显示有关该连接上使用的 GSSAPI 认证和加密的信息。有关详细信息,请参阅pg_stat_gssapi。 | 现存 | |||
pg_stat_io |
16 | 20 | 181 次 | |
| 对于每种后端类型、上下文和目标对象的组合各有一行,包含集簇范围的 I/O 统计信息。有关详细信息,请参阅pg_stat_io。 | 现存 | |||
pg_stat_kind_info |
20 | 7 | — | |
| 每个已注册的统计信息类型一行,显示各类型的信息。详见pg_stat_kind_info。 | 现存 | |||
pg_stat_lock |
19 | 5 | — | |
| 每种锁类型一行,显示集簇范围的锁统计信息。有关详细信息,请参阅pg_stat_lock。 | 现存 | |||
pg_stat_recovery |
19 | 9 | — | |
| 至多一行,显示有关恢复状态的统计信息。有关详细信息,请参阅pg_stat_recovery。 | 现存 | |||
pg_stat_recovery_prefetch |
15 | 10 | — | |
| 只有一行,显示了恢复过程中预取的块的统计信息。 详细信息请参见 pg_stat_recovery_prefetch。 | 现存 | |||
pg_stat_replication |
9.1 | 20 | 124 次 | |
| 每个 WAL 发送进程一行,显示有关复制到该发送进程所连接备库的统计信息。有关详细信息,请参阅pg_stat_replication。 | 现存 | |||
pg_stat_replication_slots |
14 | 13 | 191 次 | |
| 每个复制槽一行,显示有关复制槽使用情况的统计信息。有关详细信息,请参阅pg_stat_replication_slots。 | 现存 | |||
pg_stat_slru |
13 | 9 | — | |
| 每个 SLRU 一行,显示操作统计信息。有关详细信息,请参阅pg_stat_slru。 | 现存 | |||
pg_stat_ssl |
9.5 | 8 | 142 次 | |
| 每个连接(常规连接和复制连接)一行,显示有关该连接上使用的 SSL 的信息。有关详细信息,请参阅pg_stat_ssl。 | 现存 | |||
pg_stat_subscription |
10 | 11 | 172 次 | |
| 每个订阅至少一行,显示有关订阅工作进程的信息。有关详细信息,请参阅pg_stat_subscription。 | 现存 | |||
pg_stat_subscription_stats |
15 | 14 | 192 次 | |
| 每个订阅一行,显示有关错误和冲突的统计信息。有关详细信息,请参阅pg_stat_subscription_stats。 | 现存 | |||
pg_stat_sys_indexes |
9.0基线 | 10 | 192 次 | |
| 和pg_stat_all_indexes一样,但只显示系统表上的索引。 | 现存 | |||
pg_stat_sys_tables |
9.0基线 | 31 | 196 次 | |
| 和pg_stat_all_tables一样,但只显示系统表。 | 现存 | |||
pg_stat_user_functions |
9.0基线 | 7 | 192 次 | |
| 每个被跟踪的函数一行,显示有关该函数执行的统计信息。有关详细信息,请参阅pg_stat_user_functions。 | 现存 | |||
pg_stat_user_indexes |
9.0基线 | 10 | 192 次 | |
| 和pg_stat_all_indexes一样,但只显示用户表上的索引。 | 现存 | |||
pg_stat_user_tables |
9.0基线 | 31 | 196 次 | |
| 和pg_stat_all_tables一样,但只显示用户表。 | 现存 | |||
pg_stat_wal |
14 | 6 | 192 次 | |
| 只有一行,显示有关 WAL 活动的统计信息。有关详细信息,请参阅pg_stat_wal。 | 现存 | |||
pg_stat_wal_receiver |
9.6 | 15 | 132 次 | |
| 只有一行,显示有关 WAL 接收进程从其连接服务器接收到的统计信息。有关详细信息,请参阅pg_stat_wal_receiver。 | 现存 | |||
pg_stat_xact_all_tables |
9.1 | 12 | 161 次 | |
| 和pg_stat_all_tables相似,但计数动作只在当前事务内发生(还没有被包括在pg_stat_all_tables和相关视图中)。用于生存和死亡行数量的列以及清理和分析动作在此视图中不出现。 | 现存 | |||
pg_stat_xact_sys_tables |
9.1 | 12 | 161 次 | |
| 和pg_stat_xact_all_tables一样,但只显示系统表。 | 现存 | |||
pg_stat_xact_user_functions |
9.1 | 6 | 9.21 次 | |
| 和pg_stat_user_functions相似,但是只统计在当前事务期间的调用(还没有被包括在pg_stat_user_functions中)。 | 现存 | |||
pg_stat_xact_user_tables |
9.1 | 12 | 161 次 | |
| 和pg_stat_xact_all_tables一样,但只显示用户表。 | 现存 | |||
pg_statio_all_indexes |
9.0基线 | 8 | 191 次 | |
| 当前数据库中的每个索引一行,显示有关访问该特定索引的 I/O 统计信息。有关详细信息,请参阅pg_statio_all_indexes。 | 现存 | |||
pg_statio_all_sequences |
9.0基线 | 6 | 191 次 | |
| 当前数据库中的每个序列一行,显示有关访问该特定序列的 I/O 统计信息。有关详细信息,请参阅pg_statio_all_sequences。 | 现存 | |||
pg_statio_all_tables |
9.0基线 | 12 | 191 次 | |
| 当前数据库中的每个表一行,显示有关访问该特定表的 I/O 统计信息。有关详细信息,请参阅pg_statio_all_tables。 | 现存 | |||
pg_statio_sys_indexes |
9.0基线 | 8 | 191 次 | |
| 和pg_statio_all_indexes一样,但只显示系统表上的索引。 | 现存 | |||
pg_statio_sys_sequences |
9.0基线 | 6 | 191 次 | |
| 和pg_statio_all_sequences一样,但只显示系统序列(目前没有定义系统序列,因此这个视图总是为空)。 | 现存 | |||
pg_statio_sys_tables |
9.0基线 | 12 | 191 次 | |
| 和pg_statio_all_tables一样,但只显示系统表。 | 现存 | |||
pg_statio_user_indexes |
9.0基线 | 8 | 191 次 | |
| 和pg_statio_all_indexes一样,但只显示用户表上的索引。 | 现存 | |||
pg_statio_user_sequences |
9.0基线 | 6 | 191 次 | |
| 和pg_statio_all_sequences一样,但只显示用户序列。 | 现存 | |||
pg_statio_user_tables |
9.0基线 | 12 | 191 次 | |
| 和pg_statio_all_tables一样,但只显示用户表。 | 现存 | |||