pg_stat_io 是一个 统计视图,显示集群范围内的 I/O(输入/输出)统计信息。
pg_stat_io 在 PostgreSQL 16 中添加。
按 PostgreSQL 版本定义
pg_stat_io (PostgreSQL 19)
View "pg_catalog.pg_stat_io"
Column | Type | Collation | Nullable | Default
----------------+--------------------------+-----------+----------+---------
backend_type | text | | |
object | text | | |
context | text | | |
reads | bigint | | |
read_bytes | numeric | | |
read_time | double precision | | |
writes | bigint | | |
write_bytes | numeric | | |
write_time | double precision | | |
writebacks | bigint | | |
writeback_time | double precision | | |
extends | bigint | | |
extend_bytes | numeric | | |
extend_time | double precision | | |
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 18)
View "pg_catalog.pg_stat_io"
Column | Type | Collation | Nullable | Default
----------------+--------------------------+-----------+----------+---------
backend_type | text | | |
object | text | | |
context | text | | |
reads | bigint | | |
read_bytes | numeric | | |
read_time | double precision | | |
writes | bigint | | |
write_bytes | numeric | | |
write_time | double precision | | |
writebacks | bigint | | |
writeback_time | double precision | | |
extends | bigint | | |
extend_bytes | numeric | | |
extend_time | double precision | | |
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 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 18
- 添加了以下列 (提交 f92c854c)
read_byteswrite_bytes
- 添加了以下列 (提交 f92c854c)
- 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
有用链接
- 等待 PostgreSQL 16:使用 pg_stat_io 的累计 I/O 统计信息 - 2023 年 2 月 Lukas Fittl / pganalyze 的博客文章
