此条目涉及PostgreSQL的一个功能,该功能是PostgreSQL 17的一部分,预计将于2024年底发布。
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 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 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 17 文档: pg_stat_checkpointer
有用链接
- PostgreSQL 17:新的目录视图pg_stat_checkpointer - Daniel Westermann于2023年11月的博客文章