Cookbook recipe

Flatten I/O spikes by tuning checkpoints

Applies to PostgreSQL 13–17 Last reviewed May 2026 Grounded in source
Estimated investigation4 min

Scenario

Every few minutes write latency spikes. Checkpoints are flushing too much dirty data at once. Spreading them out smooths the I/O. Diagnose it Check checkpoint frequency and whether they are forced: SELECT * FROM pg_stat_bgwriter; --…

Investigation Path

Every few minutes write latency spikes. Checkpoints are flushing too much dirty data at once. Spreading them out smooths the I/O.

Diagnose it

Check checkpoint frequency and whether they are forced:

SELECT * FROM pg_stat_bgwriter;
-- checkpoints_timed vs checkpoints_req: many 'req' means too-small max_wal_size

Why it happens

A checkpoint writes all dirty buffers to disk. If checkpoints are forced by filling max_wal_size too often, they bunch up. A short checkpoint_completion_target compresses the write burst into a small window.

This is a Pro lesson

Get every Learning Pathway and cookbook recipe — grounded in PostgreSQL source code, with diagnostics, fixes, and prevention for each topic.

Continue this lesson to learn:

  • How to fix it
  • Prevent it next time
  • Related & next steps
  • All 36 Learning Pathway lessons
  • 170+ cookbook recipes
  • Source-grounded diagnostics & fixes

Secure checkout Cancel anytime Source-grounded

Career Impact

This scenario builds production judgment and operational confidence under pressure.

Open Career Dashboard →

Keep going

Related & next steps

Was this helpful?

← All cookbook recipes