PostgreSQL Enterprise (50 Qs)•Part 3: Advanced Internals, Scale & Production Patterns (Senior / Lead)
How does PostgreSQL handle Checkpoint Spikes and how do you tune `checkpoint_completion_target`?
senior LevelDatabases & SQLPostgreSQL
In Simple Words: During a Checkpoint, PostgreSQL flushes thousands of dirty shared buffers to disk:
- Writing all pages at once creates a massive disk I/O bottleneck that freezes client queries.
- Tuning: Set
checkpoint_completion_target = 0.9. - Instructs PostgreSQL to spread disk writes smoothly across 90% of the checkpoint duration interval (
checkpoint_timeout, default 15 minutes), flattening I/O spikes.