Parameter · Write-Ahead Log / Settings
wal_writer_delay
Time between WAL flushes performed in the WAL writer.
- Default:
200ms - Type: integer (ms)
- Range: 1ms … 10s
- Applies: Reload
In plain words
The WAL writer is a background process that regularly writes WAL from memory to disk, so commits and sessions find less work left to do. wal_writer_delay is how long it sleeps between rounds.
It matters most with synchronous_commit = off: asynchronous commits become durable when the WAL writer flushes them, so this setting bounds how much could be lost in a crash.
For DBAs and operators
Each round the WAL writer writes out completed WAL pages. Whether it also flushes (fsyncs) depends on wal_writer_flush_after: if less than that was written and the last flush was less than wal_writer_delay ago, it only writes to the OS. It hibernates (sleeps longer) when there is no activity, and asynchronous commits wake it early.
Worst-case loss window for synchronous_commit = off is about 3 × wal_writer_delay (600 ms with the default 200 ms). Lowering it (e.g. 10–50 ms) shrinks that window at the cost of more, smaller writes. Raising it rarely helps.
Observe it: SELECT * FROM pg_stat_activity WHERE backend_type = 'walwriter'; (wait event WalWriterMain while sleeping), and its I/O in pg_stat_io where backend_type = 'walwriter'.
How to change it
Change in postgresql.conf or ALTER SYSTEM, then run SELECT pg_reload_conf().