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 grows. 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. The database server -gc option controls the maximum time, in minutes, between checkpoints. You can also set the time using the checkpoint_time option. See checkpoint_time option [database].

  • Recovery Urgency   A heuristic to estimate the amount of time required to recover the database if it fails right now. The database server -gr option controls the maximum time, in minutes, for recovery in the event of system failure. You can also set the time using the recovery_time option. See recovery_time option [database].

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

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

There are two database options that allow you to control the frequency of checkpoints. checkpoint_time controls the maximum time between checkpoints and recovery_time controls the maximum time for recovery in the event of system failure.

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

Both the checkpoint urgency and recovery urgency values increase in value until the checkpoint occurs, at which point they drop to zero. They do not decrease otherwise.

See also