Christophe Pettus: All Your GUCs in a Row: bgwriter_lru_maxpages and bgwriter_lru_multiplier
The article discusses two important PostgreSQL parameters, bgwriter_lru_maxpages and bgwriter_lru_multiplier, which influence the performance of the background writer. These parameters help manage how many buffers the bgwriter can write in a cycle and how it predicts buffer demand. Proper tuning of these settings is crucial for optimizing database performance, especially in varying workload scenarios.
- ▪bgwriter_lru_maxpages sets the maximum number of buffers the bgwriter will write in a single cycle, with a default of 100.
- ▪bgwriter_lru_multiplier is a scaling factor that determines how many clean buffers the bgwriter aims to make available, with a default of 2.0.
- ▪Monitoring the pg_stat_bgwriter metrics can help diagnose whether adjustments to these parameters are necessary for optimal performance.
Opening excerpt (first ~120 words) tap to expand
2026-05-16 4 min PostgreSQL All Your GUCs in a Row: bgwriter_lru_maxpages and bgwriter_lru_multiplier These two parameters close out the bgwriter cluster. Together with bgwriter_delay, they govern how the background writer decides what to write each round, and they are where the actual leverage lives — the previous post ended by saying so explicitly. Here is why. The bgwriter’s algorithm, in one paragraph Each cycle, the bgwriter estimates how many buffers will be needed by backends in the near future. It does this by averaging the number of new buffers requested over recent cycles. It multiplies that average by bgwriter_lru_multiplier to get a target number of clean buffers to make available.
…
Excerpt limited to ~120 words for fair-use compliance. The full article is at Postgr.