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

STATISTICS VIEW · 统计视图

pg_stat_io

The pg_stat_io view will contain one row for each combination of backend type, target I/O object, and I/O context, showing cluster-wide I/O statistics. Combinations which do not make sense are omitted. Currently, I/O on relations (e.g. tables, indexes) and WAL activity are tracked. However, relation I/O which bypasses shared buffers (e.g. when moving a table from one tablespace to another) is currently not tracked. Some backend types never perform I/O operations on some I/O objects and/or in some I/O contexts. These rows are omitted from the view. For example, the checkpointer does not checkpoint temporary tables, so there will be no rows for backend_type checkpointer and object temp relation. In addition, some I/O operations will never be performed either by certain backend types or on certain I/O objects and/or in certain I/O contexts. These cells will be NULL. For example, temporary tables are not fsynced, so fsyncs will be NULL for object temp relation. Also, the background writer does not perform reads, so reads will be NULL in rows for backend_type background writer. For the object wal, fsyncs and fsync_time track the fsync activity of WAL files done in issue_xlog_fsync. writes and write_time track the write activity of WAL files done in XLogWrite. See Section 28.5 for more information. pg_stat_io can be used to inform database tuning. For example:

首次收录 PG 16最近收录 PG 19当前字段 20

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

字段结构 PostgreSQL 18

pg_stat_io
字段 / COLUMN类型 / TYPE说明 / DESCRIPTION
backend_type text Type of backend (e.g. background worker, autovacuum worker). See pg_stat_activity for more information on backend_types. Some backend_types do not accumulate I/O operation statistics and will not be included in the view.
object text Target object of an I/O operation. Possible values are:
context text The context of an I/O operation. Possible values are:
reads bigint Number of read operations.
read_bytes numeric The total size of read operations in bytes.
read_time double precision 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)
writes bigint Number of write operations.
write_bytes numeric The total size of write operations in bytes.
write_time double precision 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)
writebacks bigint Number of units of size BLCKSZ (typically 8kB) which the process requested the kernel write out to permanent storage.
writeback_time double precision 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.
extends bigint Number of relation extend operations.
extend_bytes numeric The total size of relation extend operations in bytes.
extend_time double precision 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)
hits bigint The number of times a desired block was found in a shared buffer.
evictions bigint Number of times a block has been written out from a shared or local buffer in order to make it available for another use. In context normal, this counts the number of times a block was evicted from a buffer and replaced with another block. In contexts bulkwrite, bulkread, and vacuum, this counts the number of times a block was evicted from shared buffers in order to add the shared buffer to a separate, size-limited ring buffer for use in a bulk I/O operation.
reuses bigint The number of times an existing buffer in a size-limited ring buffer outside of shared buffers was reused as part of an I/O operation in the bulkread, bulkwrite, or vacuum contexts.
fsyncs bigint Number of fsync calls. These are only tracked in context normal.
fsync_time double precision 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)
stats_reset timestamp with time zone Time at which these statistics were last reset.

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

字段演化矩阵

悬停查看字段类型
存在新增 / 类型或属性变化移除
字段 / COLUMN9.09.19.29.39.49.59.610111213141516171819
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

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

演化时间线

相邻大版本的变化

PostgreSQL 19 ← 18

1 处字段说明更新

PostgreSQL 18 ← 17

+ read_bytes+ write_bytes+ extend_bytes− op_bytes9 处字段说明更新目录说明更新

PostgreSQL 16 ← 15新增目录

+ 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

比较任意两个版本

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