pg_stat_checkpointer
是一个 系统统计视图,显示有关 检查点 的信息。
pg_stat_checkpointer
在 PostgreSQL 17 中添加,其中包含先前包含在 pg_stat_bgwriter
中的一些信息。
统计重置
可以通过执行以下命令重置 pg_stat_checkpointer
显示的统计信息:
SELECT pg_stat_reset_shared('checkpointer')
按PostgreSQL版本定义
pg_stat_checkpointer (PostgreSQL 18)
View "pg_catalog.pg_stat_checkpointer" Column | Type | Collation | Nullable | Default ---------------------+--------------------------+-----------+----------+--------- num_timed | bigint | | | num_requested | bigint | | | num_done | bigint | | | restartpoints_timed | bigint | | | restartpoints_req | bigint | | | restartpoints_done | bigint | | | write_time | double precision | | | sync_time | double precision | | | buffers_written | bigint | | | slru_written | bigint | | | stats_reset | timestamp with time zone | | |
pg_stat_checkpointer (PostgreSQL 17)
View "pg_catalog.pg_stat_checkpointer" Column | Type | Collation | Nullable | Default ---------------------+--------------------------+-----------+----------+--------- num_timed | bigint | | | num_requested | bigint | | | restartpoints_timed | bigint | | | restartpoints_req | bigint | | | restartpoints_done | bigint | | | write_time | double precision | | | sync_time | double precision | | | buffers_written | bigint | | | stats_reset | timestamp with time zone | | |
更改历史
- PostgreSQL 18
- 添加列
num_done
(提交 559efce1)
- 添加列
- PostgreSQL 17
- 添加 (提交 96f05261)
示例
pg_stat_checkpointer
的基本用法示例
postgres=# SELECT * FROM pg_stat_checkpointer; num_timed | num_requested | write_time | sync_time | buffers_written | stats_reset -----------+---------------+------------+-----------+-----------------+------------------------------- 1 | 1 | 4514 | 2 | 76 | 2023-10-31 10:31:48.064606+09 (1 row) postgres=# CHECKPOINT; CHECKPOINT postgres=# SELECT * FROM pg_stat_checkpointer; num_timed | num_requested | write_time | sync_time | buffers_written | stats_reset -----------+---------------+------------+-----------+-----------------+------------------------------- 1 | 2 | 4516 | 3 | 76 | 2023-10-31 10:31:48.064606+09 (1 row)
重置 pg_stat_checkpointer
统计信息
postgres=# SELECT pg_stat_reset_shared('checkpointer'); pg_stat_reset_shared ---------------------- (1 row) postgres=# SELECT * FROM pg_stat_checkpointer; num_timed | num_requested | write_time | sync_time | buffers_written | stats_reset -----------+---------------+------------+-----------+-----------------+------------------------------- 0 | 0 | 0 | 0 | 0 | 2023-10-31 10:48:28.553766+09 (1 row)
参考文献
- PostgreSQL文档: pg_stat_checkpointer
有用链接
- PostgreSQL 17:新的目录视图 pg_stat_checkpointer - Daniel Westermann 于 2023 年 11 月撰写的博客文章