Scrivio Interview library
DebuggingIntermediate6 min read · updated 12 November 2026

A PostgreSQL log repeatedly shows: LOG: checkpoints are occurring too frequently (24 seconds apart) HINT: Consider increasing the configuration parameter "max_wal_size". At the same time, write latency spikes during a nightly bulk load. Explain the message, the effect on I/O and WAL, and what you would change.

The message means that checkpoints are being forced by WAL volume, not by time: a checkpoint starts when checkpoint_timeout passes or when the WAL written since the last one reaches max_wal_size, and the nightly bulk load fills max_wal_size every 24 seconds. Each checkpoint flushes dirty pages and makes the next change to every page write a full-page image, so WAL and I/O balloon and write latency spikes. I would raise max_wal_size to tens of gigabytes if the disk allows, keep checkpoint_completion_target near 0.9, confirm with pg_stat_checkpointer or pg_stat_bgwriter that checkpoints become timed, and make the load itself cheaper with COPY, batching, unlogged staging tables and indexes built after the load.

Why this question is asked

This log line is one of the most common PostgreSQL warnings, and it comes with its own hint, yet the hint alone does not explain why the latency spikes or what else to change. Interviewers use it as a debugging exercise: can we read the message, explain the mechanism behind the symptoms and choose fixes with their costs? In this answer, we will decode the message, follow what each forced checkpoint does to I/O and WAL, change the settings, check the result in the statistics views, and make the bulk load lighter.

1What the Message Says

PostgreSQL starts a checkpoint for one of two reasons: checkpoint_timeout has passed since the last one (5 minutes by default), or the WAL written since the last one has reached a level derived from max_wal_size (1 GB by default). The second kind is called a requested checkpoint. If requested checkpoints follow each other closer than checkpoint_warning (30 seconds by default), PostgreSQL logs this warning and suggests raising max_wal_size.

So the log tells us that during the bulk load the database is writing roughly 1 GB of WAL every 24 seconds, about 40 MB per second, and that every 24 seconds it is forced into a new checkpoint. The time-based schedule of 5 minutes never gets a chance.

Java
LOG: checkpoints are occurring too frequently (24 seconds apart)
HINT: Consider increasing the configuration parameter "max_wal_size".
LOG: checkpoint starting: wal
LOG: checkpoint complete: wrote 61234 buffers (37.4%); ... total=23.1 s; distance=1048576 kB
-- "starting: wal" = requested by WAL volume; "distance" about 1 GB = the max_wal_size budget

2Why Forced Checkpoints Hurt the Load

Each checkpoint writes every dirty page in shared_buffers to the data files and fsyncs them. Normally checkpoint_completion_target spreads those writes over 90 percent of the interval; with a 24-second interval there is barely any time to spread them, so the writes arrive in bursts that compete with the load's own I/O. The fsync at the end of each checkpoint can stall the disk briefly, and that is where the latency spikes come from.

There is a worse feedback loop in the WAL. With full_page_writes on, the first change to each page after a checkpoint writes the entire 8 KB page into the WAL. A bulk load touches a huge number of pages, both table and index pages, so after every checkpoint it starts writing full-page images again. More frequent checkpoints mean more page images, which means more WAL, which fills max_wal_size even sooner and triggers the next checkpoint. Replicas and the WAL archive must then carry all that extra volume too.

Step throughThe loop during the bulk load
  1. Load writes rows and index entriesabout 40 MB of WAL per second
  2. WAL since checkpoint reaches max_wal_size1 GB after about 24 seconds
  3. Requested checkpointdirty pages written in a burst, fsync
  4. Next change to each page writes a full-page imageWAL grows faster
  5. max_wal_size reached soonerthe loop repeats

5 steps in order. Play them, or step through them one at a time.

Small max_wal_size and full-page images feed each other during heavy writes.

3Changing the Settings

The main fix is the one the hint suggests: give the load enough WAL budget that checkpoints happen on time, not on volume. If the load writes 40 MB per second and we want a checkpoint about every 15 minutes, we need about 36 GB of WAL between checkpoints, so max_wal_size of 32 to 64 GB, provided the WAL disk has room for it plus a margin. We raise checkpoint_timeout to 15 minutes so the timed schedule is reasonable, and keep checkpoint_completion_target at 0.9, the default since PostgreSQL 14, so writes are spread over most of the interval. checkpoint_warning itself only controls the message, so we leave it alone.

SQL
ALTER SYSTEM SET max_wal_size = '48GB';
ALTER SYSTEM SET checkpoint_timeout = '15min';
ALTER SYSTEM SET checkpoint_completion_target = 0.9;
SELECT pg_reload_conf(); -- these three take effect on reload, no restart needed

4Checking the Result

We confirm with the statistics views. In PostgreSQL 17 and later, pg_stat_checkpointer shows num_timed and num_requested; in older versions the same counters are checkpoints_timed and checkpoints_req in pg_stat_bgwriter. Before the change, requested checkpoints dominate during the load. After it, nearly all should be timed. We also compare WAL generated per night, from pg_current_wal_lsn() before and after the load or from pg_stat_wal, which usually drops noticeably because fewer full-page images are written.

SQL
SELECT num_timed, num_requested, write_time, sync_time FROM pg_stat_checkpointer; -- PostgreSQL 17+
-- before: 288 | 1490 | ... ; after the change, one night: 32 | 2
SELECT checkpoints_timed, checkpoints_req FROM pg_stat_bgwriter; -- PostgreSQL 16 and older

5Making the Bulk Load Itself Cheaper

The settings stop the checkpoint storm, but the load can also produce less WAL and less work. COPY is much faster than individual INSERT statements, and if we must insert from an application, batching hundreds of rows per statement and per transaction helps a lot. Loading into an unlogged staging table writes no WAL for that table at all; we then transform and insert into the real table in one set-based statement. The staging data is lost on a crash, which is fine because we can reload it.

Indexes are a large share of the work: each row inserted into a table with five indexes writes six structures. For a full reload, it is far cheaper to load into a table without secondary indexes and build them afterwards, because a single CREATE INDEX sorts the data once and writes compact pages. For loads into a live table that must stay indexed, we keep the indexes but spread the load over a longer window.

Bulk load options and their effect
OptionSavesWatch out for
COPY instead of INSERTstatement overhead, round tripserror handling for bad rows
unlogged staging tableall WAL for the staging datalost on crash, not on replicas
build indexes after the loadindex WAL and random page writesonly for new or swapped tables
larger max_wal_sizeforced checkpoints, page imagesWAL disk space, recovery time

6Follow-up questions

What is the cost of a much larger max_wal_size?

More WAL can accumulate between checkpoints, so the pg_wal directory needs that much disk plus a margin, and after a crash PostgreSQL must replay up to that much WAL, which can take several minutes for tens of gigabytes. max_wal_size is a soft limit, so WAL can exceed it under heavy load or when archiving or a replication slot falls behind. We size it so recovery time stays within our objectives.

Why does the hint not suggest raising checkpoint_timeout?

Because the checkpoints are triggered by WAL volume, not by time. Raising the timeout alone changes nothing while max_wal_size is reached every 24 seconds. Both must be raised together for longer intervals to happen.

Is it safe to turn off full_page_writes during the load?

No, unless the storage guarantees atomic page writes. A crash during the load could leave torn pages that WAL replay cannot repair, corrupting data. Reducing checkpoints, enabling wal_compression and loading more efficiently are the safe ways to reduce page images.

7Conclusion

In this answer, we saw that the warning means checkpoints are being requested by WAL volume every 24 seconds because the bulk load fills max_wal_size that fast. Each forced checkpoint writes dirty pages in a burst and restarts full-page images, so WAL grows and write latency spikes. We raise max_wal_size and checkpoint_timeout, keep checkpoint_completion_target near 0.9, confirm with pg_stat_checkpointer or pg_stat_bgwriter that checkpoints become timed, and make the load lighter with COPY, batching, unlogged staging tables and indexes built after the load.

What to say in the interviewAbout 100 seconds aloud

Open with

The message says checkpoints are being triggered by WAL volume rather than by time. A checkpoint starts when checkpoint_timeout passes, five minutes by default, or when the WAL since the last checkpoint reaches max_wal_size, one gigabyte by default, and if those WAL-triggered checkpoints come closer than checkpoint_warning, thirty seconds, PostgreSQL logs this.

Then, if they want more

So the load is writing about a gigabyte of WAL every 24 seconds. Each checkpoint has to write all dirty buffers and fsync, and with a 24-second interval it cannot spread the writes, so they come in bursts that compete with the load and cause the latency spikes.

It also feeds itself: after every checkpoint the first change to each page writes a full 8 KB page image to the WAL, and a bulk load touches lots of table and index pages, so WAL grows faster and the next checkpoint comes sooner.

I would raise max_wal_size to tens of gigabytes, for example 48 GB if the WAL disk allows, raise checkpoint_timeout to around 15 minutes, keep checkpoint_completion_target at 0.9, and then confirm in pg_stat_checkpointer on 17 or pg_stat_bgwriter on older versions that requested checkpoints have dropped to almost none, and that nightly WAL volume fell.

The trade-off is more disk for pg_wal and a longer crash recovery. Then I would fix the load itself: COPY instead of row inserts, batching, an unlogged staging table that writes no WAL, and for full reloads building the indexes after loading.

About this answer

Last updated
12 November 2026
Versions it names
PostgreSQL 17, PostgreSQL 14, PostgreSQL 16
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.
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 "A PostgreSQL log repeatedly shows: LOG: checkpoints are occurring too frequently (24...": https://scrivio-interview-library.netlify.app/databases/storage-internals/a2219dbdc5/