stat_checkpointer collector exposes checkpoint and restartpoint statistics from the checkpointer process.
Status
Default: Disabled Enable with:--collector.stat-checkpointer
Metrics
pg_stat_checkpointer_num_timed_total
Type: CounterDescription: Number of scheduled checkpoints due to timeout
pg_stat_checkpointer_num_requested_total
Type: CounterDescription: Number of requested checkpoints that have been performed
pg_stat_checkpointer_restartpoints_timed_total
Type: CounterDescription: Number of scheduled restartpoints due to timeout or after a failed attempt to perform it
pg_stat_checkpointer_restartpoints_req_total
Type: CounterDescription: Number of requested restartpoints
pg_stat_checkpointer_restartpoints_done_total
Type: CounterDescription: Number of restartpoints that have been performed
pg_stat_checkpointer_write_time_total
Type: CounterDescription: Total amount of time spent writing checkpoint and restartpoint files to disk, in milliseconds
pg_stat_checkpointer_sync_time_total
Type: CounterDescription: Total amount of time spent synchronizing checkpoint and restartpoint files to disk, in milliseconds
pg_stat_checkpointer_buffers_written_total
Type: CounterDescription: Number of buffers written during checkpoints and restartpoints
pg_stat_checkpointer_stats_reset_total
Type: CounterDescription: Time at which these statistics were last reset (Unix timestamp)
SQL Query
PostgreSQL Versions
Supported: PostgreSQL 17+ only Background: In PostgreSQL 17, checkpoint-related statistics were moved frompg_stat_bgwriter to the new pg_stat_checkpointer view.
Required Permissions
The monitoring user needs:- Access to
pg_stat_checkpointerview (granted toPUBLICby default)
Example Output
Use Cases
Monitor Checkpoint Frequency
Checkpoint Performance
Restartpoint Monitoring (Replicas)
Checkpoints vs Restartpoints
- Checkpoints: Performed on primary servers to ensure data consistency
- Restartpoints: Similar to checkpoints but performed on standby servers during recovery
Tuning Recommendations
High num_requested
If requested checkpoints are frequent:
- Increase
max_wal_size - Increase
checkpoint_timeout - Monitor write load on the primary
High Write/Sync Times
If checkpoint I/O is slow:- Check storage performance
- Adjust
checkpoint_completion_target - Consider faster storage
Failed Restartpoints
Ifrestartpoints_req > restartpoints_done:
- Restartpoints are being skipped
- May indicate heavy replay activity
- Check replica performance
Alert Examples
Migration from PostgreSQL 16
If upgrading from PostgreSQL 16 to 17:- Enable this collector:
--collector.stat-checkpointer - Checkpoint metrics will no longer appear in
pg_stat_bgwriter - Update dashboards and alerts to use new metric names
Related
- pg_stat_checkpointer view
- Checkpoint documentation
- stat-bgwriter collector (PostgreSQL less than 17)