Parameter · Resource Usage / Background Writer
bgwriter_lru_maxpages
Background writer maximum number of LRU pages to flush per round. 0 disables background writing.
- Default:
100 - Type: integer
- Range: 0 … 1073741823
- Applies: Reload
In plain words
A hard cap on how much the background writer may do in one round. If demand is higher, sessions have to write dirty pages themselves before they can reuse a buffer, which slows their queries. 0 turns the background writer's cleaning off entirely (checkpoints still happen).
For DBAs and operators
Each round the bgwriter predicts how many buffers backends will need (recent allocations × bgwriter_lru_multiplier), scans ahead of the clock-sweep hand and writes dirty buffers until it has that many clean, reusable ones, but never more than bgwriter_lru_maxpages. Every round that stopped because of this cap increments pg_stat_bgwriter.maxwritten_clean; buffers_clean counts buffers it wrote.
Tuning signal: client backends doing a large share of writes in pg_stat_io (backend_type = 'client backend', context = 'normal') and a steadily rising maxwritten_clean. Typical busy-server values: 200–1000 with bgwriter_delay 10–100 ms. Downside: a buffer cleaned by the bgwriter may be dirtied again before eviction, so more total I/O. It is not a substitute for proper checkpoint tuning.
How to change it
Change in postgresql.conf or ALTER SYSTEM, then run SELECT pg_reload_conf().