检查点是数据库实例恢复机制的关键,其目的是为了确定某个时间点之前的脏数据已经全部存盘了。频繁的检查点会对数据库的性能产生影响,较大的checkpoint_timeout可能会导致数据文件的脏数据写入的延时加大,从而影响RTO,一般来说建议这个参数设置为20分钟以上。
SELECT
total_checkpoints,
seconds_since_start/total_checkpoints/60 AS minutes_between_checkpoints
FROM
(SELECT
EXTRACT(EPOCH FROM (now() - Pg_postmaster_start_time()))AS seconds_since_start,
(checkpoints_timed+checkpoints_req) AS total_checkpoints
FROM sys_stat_bgwriter