Parameter · Resource Usage / Background Writer
bgwriter_delay
Background writer sleep time between rounds.
- Default:
200ms - Type: integer (ms)
- Range: 10ms … 10s
- Applies: Reload
In plain words
The background writer wakes up regularly, writes some dirty pages from shared buffers to the OS so that clean pages are ready when sessions need them, and goes back to sleep for bgwriter_delay. Shorter delays mean more frequent, smaller rounds.
For DBAs and operators
Each round writes up to bgwriter_lru_maxpages buffers, so the maximum bgwriter throughput is lru_maxpages × 8 kB × (1000 / bgwriter_delay): 100 × 8 kB × 5 = 4 MB/s with defaults, which is low for busy servers. With no activity the process hibernates (sleeps much longer) and is woken by backends when they allocate buffers again. Sleep resolution is often 10 ms.
SELECT buffers_clean, maxwritten_clean, buffers_alloc
FROM pg_stat_bgwriter;
-- who writes buffers (PG16+):
SELECT backend_type, writes FROM pg_stat_io
WHERE object = 'relation' AND context = 'normal';If client backends do many writes themselves (in pg_stat_io) and maxwritten_clean keeps rising, lower the delay (e.g. 10–50 ms) and/or raise maxpages. Since PostgreSQL 17 per-backend write counts moved from pg_stat_bgwriter to pg_stat_io (and checkpointer counters to pg_stat_checkpointer).
How to change it
Change in postgresql.conf or ALTER SYSTEM, then run SELECT pg_reload_conf().
See it in context
Related parameters
bgwriter_lru_maxpages bgwriter_lru_multiplier bgwriter_flush_after shared_buffers