Quick revision
The short answer
A checkpoint is the moment at which the database guarantees that every data page changed before a certain point in the log has been written to the data files, and records that point. Changes reach the WAL or redo log at commit but reach the data pages only later, so after a crash the database replays the log from the last checkpoint; older log is no longer needed and can be recycled or archived. Frequent checkpoints shorten recovery but cost more I/O and, in PostgreSQL, more full-page images in the WAL; PostgreSQL tunes this with checkpoint_timeout, max_wal_size and checkpoint_completion_target, while InnoDB checkpoints continuously in a fuzzy way driven by redo log capacity.
What to remember
In this answer, we saw that databases write changes to the WAL or redo log at commit and write dirty pages later. A checkpoint writes all pages dirty before a recorded point and makes that point the start of crash recovery, so older log can be recycled or archived. Checkpoint spacing trades recovery time against I/O and, in PostgreSQL, against full-page images in the WAL. PostgreSQL controls it with checkpoint_timeout, max_wal_size and checkpoint_completion_target, and InnoDB checkpoints continuously and fuzzily, driven by its redo log capacity.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
A checkpoint is the moment at which the database guarantees that every data page changed before a certain point in the log has been written to the data files, and records that point. Changes reach the WAL or redo log at commit but reach the data pages only later, so after a crash the database replays the log from the last checkpoint; older log is no longer needed and can be recycled or archived. Frequent checkpoints shorten recovery but cost more I/O and, in PostgreSQL, more full-page images in the WAL; PostgreSQL tunes this with checkpoint_timeout, max_wal_size and checkpoint_completion_target, while InnoDB checkpoints continuously in a fuzzy way driven by redo log capacity.
Why this question is asked
Checkpoints sit in the background of every database we use, and we usually notice them only when they go wrong: write latency spikes every few minutes, a huge WAL volume, or a crash recovery that takes half an hour. Interviewers ask about them because they connect durability, I/O and recovery time in one mechanism. In this answer, we will recap why databases write a log before changing pages, see what a checkpoint does and why it is needed, connect it to crash recovery time, look at what frequent checkpoints cost, and finish with the settings in PostgreSQL and InnoDB.
1A Quick Recap: The Log Comes First
When we update a row, the database changes the page in its buffer pool, the in-memory cache of pages, and writes a record of the change to the write-ahead log, called the WAL in PostgreSQL and the redo log in InnoDB. At commit, only the log is flushed to disk. The changed page, now called dirty, stays in memory and is written to the data file later.
This is a deliberate design. The log is written sequentially and compactly, while the pages are scattered across the files; writing each changed 8 KB page at every commit would be far slower. The log alone is enough for durability, because after a crash the database can redo every logged change on the old page versions.
2What a Checkpoint Does
The problem with relying on the log is that it grows forever, and after a crash the database would have to replay all of it. A checkpoint solves both. In PostgreSQL, the checkpointer process notes the current position in the WAL, the redo point, then writes every page that was dirty at that moment to the data files and asks the operating system to flush them with fsync. When all of them are safely on disk, it writes a checkpoint record and updates the control file to say: recovery may start from this redo point.
From then on, WAL older than the redo point is not needed for crash recovery. PostgreSQL removes or recycles those WAL segment files, or keeps them until they have been archived if WAL archiving is on for point-in-time recovery.
6 messages in order. Play them, or step through them one at a time.
Changes keep arriving during the checkpoint; only pages dirty at the redo point must be written.
3How Checkpoints Decide Recovery Time
After a crash, the database starts from the last completed checkpoint's redo point and replays every WAL record after it, applying each change to the page it describes. The more WAL lies after that point, the longer recovery takes. So checkpoint spacing directly controls recovery time: with a checkpoint every 5 minutes, at most about 5 minutes of changes must be replayed; with a checkpoint every hour, possibly an hour's worth.
Replay speed depends on the workload and hardware, but as a rough feel, replaying several gigabytes of WAL can take minutes. That is why a database tuned for very rare checkpoints can be painfully slow to come back after a crash, and why the setting is a trade-off rather than a free performance knob.
4Why Frequent Checkpoints Cost More
Checkpoints are not free. Each one writes every dirty page, so a page updated again and again is written once per checkpoint; with more checkpoints, the same hot page is written more often. In PostgreSQL there is a second cost: with full_page_writes on, the first change to each page after a checkpoint puts a full 8 KB image of the page into the WAL, to protect against pages torn by a crash in the middle of a write. More checkpoints mean more first changes, and so more page images, which can multiply WAL volume.
So too frequent checkpoints waste I/O and inflate WAL, while too rare ones lengthen recovery and need more disk for the WAL. checkpoint_completion_target spreads each checkpoint's writes over most of the interval, so they do not arrive as one burst that slows queries.
| Frequent checkpoints | Rare checkpoints | |
|---|---|---|
| crash recovery | short, little WAL to replay | long, much WAL to replay |
| page writes | hot pages written many times | hot pages written once per long interval |
| WAL volume (PostgreSQL) | more full-page images | fewer full-page images |
| disk for WAL | small | large (max_wal_size and more) |
5Checkpoints in InnoDB
InnoDB uses fuzzy checkpointing. Instead of one large checkpoint at intervals, page cleaner threads continuously flush dirty pages from the buffer pool, oldest changes first, and the checkpoint position simply moves forward to the oldest change that is still only in memory. Recovery starts from that position. What drives the flushing is the space in the redo log, which is circular: it has a fixed capacity, set with innodb_redo_log_capacity in recent MySQL versions (innodb_log_file_size in older ones), and InnoDB cannot overwrite redo that is still needed. As the redo log fills, InnoDB flushes more aggressively, and if it is nearly full, it must stall writes until pages are flushed. A larger redo log therefore smooths writes and lengthens recovery, the same trade-off as in PostgreSQL.
6Follow-up questions
What is a fuzzy checkpoint?
A fuzzy checkpoint does not freeze the database and write a perfectly consistent set of pages at one instant. Pages are written while transactions keep changing other pages, and the checkpoint records a log position from which replay is guaranteed to restore everything, the oldest change not yet on disk. Some pages on disk may be newer than that point, which is fine because replay is idempotent: it skips changes a page already contains, judged by the log sequence number stored in each page. InnoDB's continuous checkpointing is fuzzy, and PostgreSQL's checkpoints are fuzzy in the same sense, since writes continue during them.
Does a checkpoint make a commit durable?
No. Commits are durable as soon as their log records are flushed. A checkpoint only makes older log unnecessary for recovery, by putting the corresponding page versions in the data files.
How can we see checkpoints happening in PostgreSQL?
log_checkpoints, on by default since PostgreSQL 15, writes a log line for each checkpoint with the number of buffers written and the time taken. pg_stat_checkpointer in PostgreSQL 17 and later, or pg_stat_bgwriter in older versions, counts checkpoints triggered by time and those requested because WAL reached max_wal_size.
7Conclusion
In this answer, we saw that databases write changes to the WAL or redo log at commit and write dirty pages later. A checkpoint writes all pages dirty before a recorded point and makes that point the start of crash recovery, so older log can be recycled or archived. Checkpoint spacing trades recovery time against I/O and, in PostgreSQL, against full-page images in the WAL. PostgreSQL controls it with checkpoint_timeout, max_wal_size and checkpoint_completion_target, and InnoDB checkpoints continuously and fuzzily, driven by its redo log capacity.
Open with
Databases make changes durable through the log, not the data files. On commit the WAL or redo record is flushed, while the changed page stays dirty in the buffer pool and is written later, because sequential log writes are much cheaper than random page writes.
Then, if they want more
A checkpoint is how the database catches the data files up. In PostgreSQL the checkpointer notes a redo point in the WAL, writes every page that was dirty at that point, fsyncs the files and records the checkpoint in the control file.
From then on, WAL before the redo point is not needed for crash recovery, so it can be recycled, or archived if we do point-in-time recovery. After a crash the database replays the WAL from the last checkpoint's redo point, so the further apart checkpoints are, the more WAL there is to replay and the longer recovery takes.
The opposite cost is that frequent checkpoints write hot pages again and again, and in PostgreSQL the first change to each page after a checkpoint writes a full page image to the WAL, so WAL volume grows.
The PostgreSQL settings are checkpoint_timeout, five minutes by default, max_wal_size, which triggers a checkpoint when that much WAL has been written, and checkpoint_completion_target, which spreads the writes over the interval. InnoDB does fuzzy checkpointing instead: page cleaners flush continuously, the checkpoint position follows the oldest unflushed change, and the pressure comes from the size of the circular redo log.
About this answer
- Last updated
- 12 November 2026
- Versions it names
- PostgreSQL 15, PostgreSQL 17
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- PostgreSQL documentation, MySQL reference manual
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "What is a checkpoint in a database such as PostgreSQL or InnoDB, why is it needed, and...": https://scrivio-interview-library.netlify.app/databases/storage-internals/718dd9e654/