STATISTICS VIEW统计视图
pg_stat_io
对于每种后端类型、上下文和目标对象的组合各有一行,包含集簇范围的 I/O 统计信息。有关详细信息,请参阅pg_stat_io。
统计视图 引入 16 现存至 20 devel 1 次结构变更
版本轨迹
相对 PostgreSQL 17:新增 3 个字段,移除 1 个,描述更新 9 处。
pg_stat_io 视图对每种后端类型、目标 I/O 对象和 I/O 上下文的组合各提供一行,显示整个集簇范围内的 I/O 统计信息。没有意义的组合会被省略。
目前会跟踪关系(例如表、索引)的 I/O 以及 WAL 活动。不过,绕过共享缓冲区的关系 I/O(例如将表从一个表空间移动到另一个表空间时)目前不会被跟踪。
字段
PostgreSQL 18 的 20 个字段,按定义顺序排列。说明默认用本站手册的译文,没有译文的按英文原文显示。
| 字段 | 类型 | 说明 |
|---|---|---|
backend_type
|
text
|
后端类型(例如后台工作进程、autovacuum 工作进程)。有关 backend_type 的更多信息,请参阅pg_stat_activity。某些 backend_type 不会累计 I/O 操作统计信息,因此不会出现在该视图中。 |
object
|
text
|
I/O 操作的目标对象。可能的值有: |
context
|
text
|
I/O 操作的上下文。可能的值有: |
reads
|
bigint
|
读取操作的数量。 |
read_bytes
新
|
numeric
|
读取操作的总大小(以字节为单位)。 |
read_time
|
double precision
|
等待读取操作所花费的时间,以毫秒计(如果启用了 track_io_timing 且 object 不是 wal,或者启用了 track_wal_io_timing 且 object 是 wal;否则为零)。 |
writes
|
bigint
|
写入操作的数量。 |
write_bytes
新
|
numeric
|
写入操作的总大小(以字节为单位)。 |
write_time
|
double precision
|
等待写入操作所花费的时间,以毫秒计(如果启用了 track_io_timing 且 object 不是 wal,或者启用了 track_wal_io_timing 且 object 是 wal;否则为零)。 |
writebacks
|
bigint
|
进程请求内核写出到永久存储的、大小为 BLCKSZ(通常为 8kB)的单位数量。 |
writeback_time
|
double precision
|
等待写回操作所花费的时间,以毫秒计(如果启用了 track_io_timing,否则为零)。这包括排队写出请求所花费的时间,以及可能实际写出脏数据所花费的时间。 |
extends
|
bigint
|
关系扩展操作的数量。 |
extend_bytes
新
|
numeric
|
关系扩展操作的总大小(以字节为单位)。 |
extend_time
|
double precision
|
等待扩展操作所花费的时间,以毫秒计(如果启用了 track_io_timing 且 object 不是 wal,或者启用了 track_wal_io_timing 且 object 是 wal;否则为零)。 |
hits
|
bigint
|
在共享缓冲区中找到所需块的次数。 |
evictions
|
bigint
|
为了腾出空间供其他用途而将块从共享或本地缓冲区写出的次数。 在 context 为 normal 时,这会统计块从缓冲区中被驱逐并由另一个块替换的次数。在 context 为 bulkwrite、bulkread 和 vacuum 时,这会统计块从共享缓冲区中被驱逐,从而把该共享缓冲区加入到单独的、大小受限的环形缓冲区中以供批量 I/O 操作使用的次数。 |
reuses
|
bigint
|
在 bulkread、bulkwrite 或 vacuum 这些 context 中,作为 I/O 操作一部分,位于共享缓冲区之外的大小受限环形缓冲区中已有缓冲区被重用的次数。 |
fsyncs
|
bigint
|
fsync 调用次数。这些只会在 context 为 normal 时被跟踪。 |
fsync_time
|
double precision
|
等待 fsync 操作所花费的时间,以毫秒计(如果启用了 track_io_timing 且 object 不是 wal,或者启用了 track_wal_io_timing 且 object 是 wal;否则为零)。 |
stats_reset
|
timestamp with time zone
|
这些统计信息上次被重置的时间。 |
本版移除的字段
-
op_bytesbigint每个 I/O 读取、写入或扩展单位的字节数。 关系数据的读取、写入和扩展以block_size为单位进行,该值 来自构建时参数BLCKSZ,默认值为8192。
取值来自 PostgreSQL 17 的快照。
演化历史
相邻两个大版本之间的差异,新的在前。版本号链到该版的字段表。
-
PostgreSQL 19 ← 18 仅描述更新
1 处描述更新
read_timeTime spent waiting for read operations in milliseconds (if track_io_timing is enabled and object is not wal, or if track_wal_io_timing is enabled and object is wal, otherwise zero) Time spent waiting for read operations in milliseconds (if track_io_timing is enabled and object is not wal, or if track_wal_io_timing is enabled and object is wal, otherwise zero). This may include time spent waiting for a read started by another backend. In that case reads may still be zero.
-
PostgreSQL 18 ← 17 结构变更
read_byteswrite_bytesextend_bytesop_bytes关系说明更新9 处描述更新
extend_timeTime spent in extend operations in milliseconds (if track_io_timing is enabled, otherwise zero) Time spent waiting for extend operations in milliseconds. (if track_io_timing is enabled and object is not wal, or if track_wal_io_timing is enabled and object is wal, otherwise zero)extendsNumber of relation extend operations, each of the size specified in op_bytes. Number of relation extend operations.fsync_timeTime spent in fsync operations in milliseconds (if track_io_timing is enabled, otherwise zero) Time spent waiting for fsync operations in milliseconds (if track_io_timing is enabled and object is not wal, or if track_wal_io_timing is enabled and object is wal, otherwise zero)read_timeTime spent in read operations in milliseconds (if track_io_timing is enabled, otherwise zero) Time spent waiting for read operations in milliseconds (if track_io_timing is enabled and object is not wal, or if track_wal_io_timing is enabled and object is wal, otherwise zero)readsNumber of read operations, each of the size specified in op_bytes. Number of read operations.write_timeTime spent in write operations in milliseconds (if track_io_timing is enabled, otherwise zero) Time spent waiting for write operations in milliseconds (if track_io_timing is enabled and object is not wal, or if track_wal_io_timing is enabled and object is wal, otherwise zero)writeback_timeTime spent in writeback operations in milliseconds (if track_io_timing is enabled, otherwise zero). This includes the time spent queueing write-out requests and, potentially, the time spent to write out the dirty data. Time spent waiting for writeback operations in milliseconds (if track_io_timing is enabled, otherwise zero). This includes the time spent queueing write-out requests and, potentially, the time spent to write out the dirty data.writebacksNumber of units of size op_bytes which the process requested the kernel write out to permanent storage. Number of units of size BLCKSZ (typically 8kB) which the process requested the kernel write out to permanent storage.writesNumber of write operations, each of the size specified in op_bytes. Number of write operations.
-
PostgreSQL 16 ← 15 新增此关系
共 18 个字段
字段矩阵
每个字段在 5 个收录版本里的存在情况;方格指向该版的字段表。「有变」指类型、可空、隐式或数组维数与上一版不同。
存在 有变 已移除 不存在
| 字段 | 16 | 17 | 18 | 19 | 20 |
|---|---|---|---|---|---|
backend_type |
存在 | 存在 | 存在 | 存在 | 存在 |
object |
存在 | 存在 | 存在 | 存在 | 存在 |
context |
存在 | 存在 | 存在 | 存在 | 存在 |
reads |
存在 | 存在 | 存在 | 存在 | 存在 |
read_time |
存在 | 存在 | 存在 | 存在 | 存在 |
writes |
存在 | 存在 | 存在 | 存在 | 存在 |
write_time |
存在 | 存在 | 存在 | 存在 | 存在 |
writebacks |
存在 | 存在 | 存在 | 存在 | 存在 |
writeback_time |
存在 | 存在 | 存在 | 存在 | 存在 |
extends |
存在 | 存在 | 存在 | 存在 | 存在 |
extend_time |
存在 | 存在 | 存在 | 存在 | 存在 |
op_bytes |
存在 | 存在 | 已移除 | 不存在 | 不存在 |
hits |
存在 | 存在 | 存在 | 存在 | 存在 |
evictions |
存在 | 存在 | 存在 | 存在 | 存在 |
reuses |
存在 | 存在 | 存在 | 存在 | 存在 |
fsyncs |
存在 | 存在 | 存在 | 存在 | 存在 |
fsync_time |
存在 | 存在 | 存在 | 存在 | 存在 |
stats_reset |
存在 | 存在 | 存在 | 存在 | 存在 |
read_bytes |
不存在 | 不存在 | 存在 | 存在 | 存在 |
write_bytes |
不存在 | 不存在 | 存在 | 存在 | 存在 |
extend_bytes |
不存在 | 不存在 | 存在 | 存在 | 存在 |
同类关系
| 关系 | 引入 | 字段 | 版本变动 | 最近变更 |
|---|---|---|---|---|
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一样,但只显示用户表。 | 现存 | |||