Try
↑ ↓ move↵ openesc close
In this lesson · topic 6 of 7
  1. 1. A disk reads pages, not keys
  2. 2. Walking down, splitting up
  3. 3. Insert thousands of keys and count the pages
  4. 4. One small record, one whole page
  5. 5. The log lets the pages wait
  6. 6. How often to write the pages out
  7. 7. Pages, splits and the log

Topic 6

How often to write the pages out

4 min read

Batching the writes

A checkpoint writes every dirty page to the data file and marks a point in the log. Recovery only has to replay the log after that point, and older log can be reused.

The longer you wait between checkpoints, the more times a hot page changes before it is written, and it is still written once. The lab shows it. With a checkpoint every 500 inserts, each insert costs 0.28measured page writes and write amplification is 10xmeasured. With a checkpoint every 5000 inserts, write amplification falls to 3.8xmeasured.

The other side

Waiting has a price the lab does not charge. After a crash the engine replays everything since the last checkpoint. A long gap means a long replay and a large log to keep. A short gap means quick recovery, and more page writes.

There is also the shape of the I/O. A checkpoint that writes all its pages at once is a burst that competes with queries. Many engines spread the writes across the interval. The right gap depends on the recovery time you can accept, not on the lowest write amplification.

Predict

You double the checkpoint interval. What changes?

Your progress is saved in this browser. Sign in to keep it on every device. Privacy · Terms