How the database server decides when to checkpoint

The priority of writing dirty pages to the disk increases as the time and the amount of work since the last checkpoint increases. The priority is determined by the following factors:

  • Checkpoint Urgency   The time that has elapsed since the last checkpoint, as a percentage of the checkpoint time setting of the database. You can set the maximum time, in minutes, between checkpoints by using the -gc server option or the checkpoint_time database option. If -gc is specified, the checkpoint_time option setting in the database is ignored.

  • Recovery Urgency   A heuristic to estimate the amount of time required to recover the database if it fails right now. You can set the maximum time, in minutes, for recovery in the event of system failure by using the -gr server option or recovery_time database option. If -gr is specified, the recovery_time option setting in the database is ignored.

The checkpoint and recovery urgency values are important only if the database server does not have enough idle time to write dirty pages. The lower boundary on the interval between checkpoints is based on a combination of the recovery_time and checkpoint_time options. The recovery_time option setting is not respected when it would force a checkpoint too soon.

Frequent checkpoints make recovery quicker, but also create work for the server writing out dirty pages.

If, because of other activity in the database, the number of dirty pages falls to zero, and if the checkpoint urgency is 33% or more, then a checkpoint takes place automatically since it is a convenient time.

Both the checkpoint urgency and recovery urgency values increase until the checkpoint occurs, at which point they drop to zero.

 See also