pg_stat_recovery_prefetch
一个统计视图,显示有关备用服务器在恢复过程中预取 WAL 块的信息
pg_stat_recovery_prefetch 是一个 统计视图,显示有关备用服务器在恢复过程中预取 WAL 块的信息。
pg_stat_recovery_prefetch 是在 PostgreSQL 15 中添加的。
用法
WAL 预取默认是禁用的,需要通过将 recovery_prefetch 设置为 on 来启用。它仅在提供有效的 posix_fadvise 操作系统级函数的系统上可用。
按 PostgreSQL 版本定义
pg_stat_recovery_prefetch (PostgreSQL 19)
View "pg_catalog.pg_stat_recovery_prefetch"
Column | Type | Collation | Nullable | Default
----------------+--------------------------+-----------+----------+---------
stats_reset | timestamp with time zone | | |
prefetch | bigint | | |
hit | bigint | | |
skip_init | bigint | | |
skip_new | bigint | | |
skip_fpw | bigint | | |
skip_rep | bigint | | |
wal_distance | integer | | |
block_distance | integer | | |
io_depth | integer | | |
pg_stat_recovery_prefetch (PostgreSQL 18)
View "pg_catalog.pg_stat_recovery_prefetch"
Column | Type | Collation | Nullable | Default
----------------+--------------------------+-----------+----------+---------
stats_reset | timestamp with time zone | | |
prefetch | bigint | | |
hit | bigint | | |
skip_init | bigint | | |
skip_new | bigint | | |
skip_fpw | bigint | | |
skip_rep | bigint | | |
wal_distance | integer | | |
block_distance | integer | | |
io_depth | integer | | |
pg_stat_recovery_prefetch (PostgreSQL 17)
View "pg_catalog.pg_stat_recovery_prefetch"
Column | Type | Collation | Nullable | Default
----------------+--------------------------+-----------+----------+---------
stats_reset | timestamp with time zone | | |
prefetch | bigint | | |
hit | bigint | | |
skip_init | bigint | | |
skip_new | bigint | | |
skip_fpw | bigint | | |
skip_rep | bigint | | |
wal_distance | integer | | |
block_distance | integer | | |
io_depth | integer | | |
pg_stat_recovery_prefetch (PostgreSQL 16)
View "pg_catalog.pg_stat_recovery_prefetch"
Column | Type | Collation | Nullable | Default
----------------+--------------------------+-----------+----------+---------
stats_reset | timestamp with time zone | | |
prefetch | bigint | | |
hit | bigint | | |
skip_init | bigint | | |
skip_new | bigint | | |
skip_fpw | bigint | | |
skip_rep | bigint | | |
wal_distance | integer | | |
block_distance | integer | | |
io_depth | integer | | |
pg_stat_recovery_prefetch (PostgreSQL 15)
View "pg_catalog.pg_stat_recovery_prefetch"
Column | Type | Collation | Nullable | Default
----------------+--------------------------+-----------+----------+---------
stats_reset | timestamp with time zone | | |
prefetch | bigint | | |
hit | bigint | | |
skip_init | bigint | | |
skip_new | bigint | | |
skip_fpw | bigint | | |
skip_rep | bigint | | |
wal_distance | integer | | |
block_distance | integer | | |
io_depth | integer | | |
变更历史
- PostgreSQL 15
- 添加(提交 5dc0418f)
示例
当 recovery_prefetch 在备用服务器上设置为 on 或 try 并且其他先决条件满足时,pg_stat_recovery_prefetch 的内容
postgres=# SELECT * FROM pg_stat_recovery_prefetch\gx -[ RECORD 1 ]--+------------------------------ stats_reset | 2022-04-30 20:45:30.247883+01 prefetch | 25 hit | 676 skip_init | 733 skip_new | 14349 skip_fpw | 59 skip_rep | 186202 wal_distance | 0 block_distance | 0 io_depth | 0
当 recovery_prefetch 设置为 off(禁用)或节点不是备用服务器时,pg_stat_recovery_prefetch 的内容
postgres=# SELECT * FROM pg_stat_recovery_prefetch\gx -[ RECORD 1 ]--+------------------------------ stats_reset | 2022-04-30 20:45:26.440076+01 prefetch | 0 hit | 0 skip_init | 0 skip_new | 0 skip_fpw | 0 skip_rep | 0 wal_distance | 0 block_distance | 0 io_depth | 0
请注意,如果 recovery_prefetch 被启用然后又被禁用,pg_stat_recovery_prefetch 将继续显示最后可用的统计信息,直到后端统计信息被重置。
参考资料
- PostgreSQL 文档: pg_stat_recovery_prefetch
