Cookbook recipe

BGWriter evictions indicate shared_buffers pressure

Applies to PostgreSQL 13–17 Last reviewed Nov 2025 Grounded in source
Estimated investigation4 min

Scenario

Backends are having to evict dirty buffers themselves (buffers_backend) because the background writer cannot keep up — a sign that shared_buffers is too small or bgwriter settings are too conservative. Diagnose it -- From pg_stat_bgwriter (columns…

Investigation Path

Backends are having to evict dirty buffers themselves (buffers_backend) because the background writer cannot keep up — a sign that shared_buffers is too small or bgwriter settings are too conservative.

Diagnose it

-- From pg_stat_bgwriter (columns present in all supported versions):
SELECT buffers_clean,
       maxwritten_clean,
       buffers_alloc,
       stats_reset
FROM pg_stat_bgwriter;

PostgreSQL 16+ note: checkpoint columns (buffers_checkpoint,
buffers_backend) moved to pg_stat_checkpointer in PG16. On PG15 and
earlier, use the richer pre-PG16 column set of pg_stat_bgwriter.

Key signals: maxwritten_clean > 0 means the bgwriter hit its page limit
per round (it stopped early); high buffers_alloc growth rate means new pages are
being allocated at a rate that outpaces cleaning.

This is a Pro lesson

Get every Learning Pathway and cookbook recipe — grounded in PostgreSQL source code, with diagnostics, fixes, and prevention for each topic.

Continue this lesson to learn:

  • Why it happens
  • How to fix it
  • Prevent it next time
  • Related & next steps
  • All 36 Learning Pathway lessons
  • 170+ cookbook recipes
  • Source-grounded diagnostics & fixes

Secure checkout Cancel anytime Source-grounded

Career Impact

This scenario builds production judgment and operational confidence under pressure.

Open Career Dashboard →

Keep going

Related & next steps

Was this helpful?

← All cookbook recipes