pg_stat_io
是一个显示集群范围 I/O 统计信息的统计视图。
pg_stat_io
在PostgreSQL 16 中添加。
按 PostgreSQL 版本定义
pg_stat_io (PostgreSQL 17)
View "pg_catalog.pg_stat_io" Column | Type | Collation | Nullable | Default ----------------+--------------------------+-----------+----------+--------- backend_type | text | | | object | text | | | context | text | | | reads | bigint | | | read_time | double precision | | | writes | bigint | | | write_time | double precision | | | writebacks | bigint | | | writeback_time | double precision | | | extends | bigint | | | extend_time | double precision | | | op_bytes | bigint | | | hits | bigint | | | evictions | bigint | | | reuses | bigint | | | fsyncs | bigint | | | fsync_time | double precision | | | stats_reset | timestamp with time zone | | |
文档: pg_stat_io
pg_stat_io (PostgreSQL 16)
View "pg_catalog.pg_stat_io" Column | Type | Collation | Nullable | Default ----------------+--------------------------+-----------+----------+--------- backend_type | text | | | object | text | | | context | text | | | reads | bigint | | | read_time | double precision | | | writes | bigint | | | write_time | double precision | | | writebacks | bigint | | | writeback_time | double precision | | | extends | bigint | | | extend_time | double precision | | | op_bytes | bigint | | | hits | bigint | | | evictions | bigint | | | reuses | bigint | | | fsyncs | bigint | | | fsync_time | double precision | | | stats_reset | timestamp with time zone | | |
文档: pg_stat_io
更改历史记录
- PostgreSQL 16
- 添加(初始提交 a9c70b46)
示例
pg_stat_io
的示例内容,此处为简洁起见省略了 stats_reset
列
postgres=# SELECT backend_type, object, context, reads, writes, extends, op_bytes, evictions, reuses, fsyncs FROM pg_stat_io; backend_type | object | context | reads | writes | extends | op_bytes | evictions | reuses | fsyncs ---------------------+---------------+-----------+-------+--------+---------+----------+-----------+--------+-------- autovacuum launcher | relation | bulkread | 0 | 0 | | 8192 | 0 | 0 | autovacuum launcher | relation | normal | 0 | 0 | | 8192 | 0 | | 0 autovacuum worker | relation | bulkread | 0 | 0 | | 8192 | 0 | 0 | autovacuum worker | relation | normal | 174 | 0 | 9 | 8192 | 0 | | 0 autovacuum worker | relation | vacuum | 145 | 0 | 0 | 8192 | 0 | 108 | client backend | relation | bulkread | 0 | 0 | | 8192 | 0 | 0 | client backend | relation | bulkwrite | 0 | 0 | 0 | 8192 | 0 | 0 | client backend | relation | normal | 223 | 0 | 0 | 8192 | 0 | | 0 client backend | relation | vacuum | 0 | 0 | 0 | 8192 | 0 | 0 | client backend | temp relation | normal | 0 | 0 | 0 | 8192 | 0 | | background worker | relation | bulkread | 0 | 0 | | 8192 | 0 | 0 | background worker | relation | bulkwrite | 0 | 0 | 0 | 8192 | 0 | 0 | background worker | relation | normal | 0 | 0 | 0 | 8192 | 0 | | 0 background worker | relation | vacuum | 0 | 0 | 0 | 8192 | 0 | 0 | background worker | temp relation | normal | 0 | 0 | 0 | 8192 | 0 | | background writer | relation | normal | | 0 | | 8192 | | | 0 checkpointer | relation | normal | | 74 | | 8192 | | | 0 standalone backend | relation | bulkread | 0 | 0 | | 8192 | 0 | 0 | standalone backend | relation | bulkwrite | 0 | 0 | 8 | 8192 | 0 | 0 | standalone backend | relation | normal | 536 | 1011 | 663 | 8192 | 0 | | 0 standalone backend | relation | vacuum | 10 | 0 | 0 | 8192 | 0 | 0 | startup | relation | bulkread | 0 | 0 | | 8192 | 0 | 0 | startup | relation | bulkwrite | 0 | 0 | 0 | 8192 | 0 | 0 | startup | relation | normal | 0 | 0 | 0 | 8192 | 0 | | 0 startup | relation | vacuum | 0 | 0 | 0 | 8192 | 0 | 0 | walsender | relation | bulkread | 0 | 0 | | 8192 | 0 | 0 | walsender | relation | bulkwrite | 0 | 0 | 0 | 8192 | 0 | 0 | walsender | relation | normal | 0 | 0 | 0 | 8192 | 0 | | 0 walsender | relation | vacuum | 0 | 0 | 0 | 8192 | 0 | 0 | walsender | temp relation | normal | 0 | 0 | 0 | 8192 | 0 | | (30 rows)
参考
- PostgreSQL 文档: pg_stat_io
有用链接
- 等待 Postgres 16:使用 pg_stat_io 获取累积 I/O 统计信息 - Lukas Fittl / pganalyze 于 2023 年 2 月发表的博文