select open change scope Open full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

CONFIGURATION / RESOURCE USAGE

bgwriter_lru_multiplier

Read PG 18 manual ↗

The number of dirty buffers written in each round is based on the number of new buffers that have been needed by server processes during recent rounds.

Type
real
Context
sighup
Measured default
2
Unit
Metadata snapshot
18

Definition PG 18 manual

The number of dirty buffers written in each round is based on the number of new buffers that have been needed by server processes during recent rounds. The average recent need is multiplied by bgwriter_lru_multiplier to arrive at an estimate of the number of buffers that will be needed during the next round. Dirty buffers are written until there are that many clean, reusable buffers available. (However, no more than bgwriter_lru_maxpages buffers will be written per round.) Thus, a setting of 1.0 represents a just in time policy of writing exactly the number of buffers predicted to be needed. Larger values provide some cushion against spikes in demand, while smaller values intentionally leave writes to be done by server processes. The default is 2.0. This parameter can only be set in the postgresql.conf file or on the server command line.

Measured default history
Version intervalDefault
9.0 – 192
Analysis & operational context

Authored guidance from the GUC source snapshot; the version-specific manual above is the definition reference. View source ↗

How it works

The background writer averages recent buffer allocations and multiplies that demand by bgwriter_lru_multiplier to choose a target number of clean reusable buffers. A value above 1 adds cushion for bursts.

This is a forecast multiplier, not a direct number of pages. Actual writes remain capped by bgwriter_lru_maxpages and occur once per bgwriter_delay round.

More cushion can reduce foreground backend writes and latency spikes, but pages dirtied repeatedly between checkpoints may be written more times, increasing total I/O. Its SIGHUP context allows configuration reload without a server restart.

Operational considerations

Changing bgwriter_lru_multiplier 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_lru_multiplier limits continuously. Measure total bytes written, checkpoints, and storage queueing, not just foreground query latency.

OLTP: Tune bgwriter_lru_multiplier 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_lru_multiplier can consume I/O needed by foreground work, so retain the default unless backend writes are a measured problem.

Version history 1
  1. PG 9.6 → 10changed

Related entries

Further reading

Definition snapshot: english-manuals:16e9883da3f32dc31546a15163a… · English manual source