// postgresql · checkpoints & recovery

bgwriter_delay

Time between rounds of the background writer, which cleans buffers ahead of other sessions.

Par défaut
200ms
Range
1ms to 10s
Restart needed
Non
Default checked on
PostgreSQL 18

Ce que cela fait

Each round the background writer writes dirty buffers picked from behind the clock-sweep hand, then sleeps this long; when it finds nothing dirty it sleeps longer regardless. bgwriter_lru_maxpages bounds what it writes per round.

Valeur par défaut

200ms. 200ms (PostgreSQL 18).

Check the current value

SHOW bgwriter_delay;

SELECT setting, unit, boot_val, context, source, pending_restart
FROM pg_settings
WHERE name = 'bgwriter_delay';

Change it

ALTER SYSTEM SET bgwriter_delay = '500ms';
SELECT pg_reload_conf();

No restart: reload with SELECT pg_reload_conf() or pg_ctl reload. It cannot be changed per session (context is sighup).

When to change it

Rarely. Compare buffers_backend with buffers_clean in pg_stat_bgwriter: when backends write most buffers themselves, a shorter delay or larger bgwriter_lru_maxpages shifts some of that work off the query path.

What can go wrong

Too short burns CPU on rounds that find little to write; too long leaves backends writing their own buffers and adds latency to their queries. It is not the checkpoint writer: checkpoints flush their own bulk, so this cannot fix checkpoint I/O spikes.

Questions about bgwriter_delay

What is the default value of bgwriter_delay in PostgreSQL?

200ms. 200ms (PostgreSQL 18).

Does changing bgwriter_delay require a restart?

No. No restart: reload with SELECT pg_reload_conf() or pg_ctl reload. It cannot be changed per session (context is sighup).

When should I change bgwriter_delay?

Rarely. Compare buffers_backend with buffers_clean in pg_stat_bgwriter: when backends write most buffers themselves, a shorter delay or larger bgwriter_lru_maxpages shifts some of that work off the query path.

Back to all PostgreSQL settings, or check the PostgreSQL manual for every option.

// one client for every engine

Check bgwriter_delay on your own server

SQLly runs the query above against PostgreSQL and the other engines in this reference, from one desktop app on macOS, Windows and Linux.

Texte et données de cette page : CC BY 4.0, en citant SQLly (sqlly.app). Code et extraits SQL : MIT. Détails de la licence