bgwriter_delay
Read PG 18 manual ↗Specifies the delay between activity rounds for the background writer.
- Type
- integer
- Context
- sighup
- Measured default
- 200 ms
- Unit
- ms
- Metadata snapshot
- 18
Definition PG 18 manual
Specifies the delay between activity rounds for the background writer. In each round the writer issues writes for some number of dirty buffers (controllable by the following parameters). It then sleeps for the length of bgwriter_delay, and repeats. When there are no dirty buffers in the buffer pool, though, it goes into a longer sleep regardless of bgwriter_delay. If this value is specified without units, it is taken as milliseconds. The default value is 200 milliseconds (200ms). Note that on some systems, the effective resolution of sleep delays is 10 milliseconds; setting bgwriter_delay to a value that is not a multiple of 10 might have the same results as setting it to the next higher multiple of 10. This parameter can only be set in the postgresql.conf file or on the server command line.
Measured default history
| Version interval | Default |
|---|---|
| 9.0 – 19 | 200 ms |
Authored guidance from the GUC source snapshot; the version-specific manual above is the definition reference. View source ↗
How it works
The background writer performs a round, writes selected dirty shared buffers, then sleeps for bgwriter_delay. When no dirty buffers are found it can enter a longer sleep regardless of this value.
A shorter interval reacts sooner to buffer demand but wakes the process more often. Effective timer granularity can be about 10 ms on some systems, so smaller or non-multiple values may round up in practice.
The number of pages considered per round is derived from recent buffer allocation demand, bgwriter_lru_multiplier, and bgwriter_lru_maxpages; checkpoints are handled separately. Its SIGHUP context allows configuration reload without a server restart.
Operational considerations
Changing bgwriter_delay without applying its documented unit and configuration context.
Optimizing an isolated benchmark while ignoring concurrent aggregate resource use.
Assuming a configured value guarantees operating-system or storage behavior.
Failing to retest startup, failover, and workload latency after the change.
Workload guidance
OLAP: Bulk writes can reach bgwriter_delay limits continuously. Measure total bytes written, checkpoints, and storage queueing, not just foreground query latency.
OLTP: Tune bgwriter_delay only with bgwriter and checkpoint metrics. The goal is fewer backend writes and smoother latency without excessive repeated writes; change one dimension at a time.
SMALL: A small host usually needs conservative write smoothing. Aggressive bgwriter_delay can consume I/O needed by foreground work, so retain the default unless backend writes are a measured problem.
Version history 3
- PG 16 → 17changed
- PG 11 → 12changed
- PG 9.1 → 9.2changed
Related entries
Further reading
Definition snapshot: english-manuals:73603db0a7a36680973278648a8… · English manual source