ReplicationReload, no restartdefault 0 MB
wal_keep_size
Sets the size of WAL files held for standby servers.
How you change it
Reload, no restart
Defaults and ranges on this page were read from pg_settings on live PostgreSQL 18.4. Treat older majors as needing their own check before you copy a value.
What this means
The amount of old WAL the primary keeps available for standbys that fall behind, even if it is not otherwise needed. It gives a lagging replica a window to catch up before its required WAL is removed. Replication slots do this more reliably, but slots can also let WAL pile up without bound.
When it matters
Set a buffer for expected replica lag, or prefer replication slots with a monitored ceiling.
| Default | 0 MB |
|---|---|
| Range | 0 – 2147483647 |
| Type | integer |
| Change scope | Reload, no restart |
| Category | Replication |
Check the current value
SHOW wal_keep_size;Tradeoffs
- • Too low: a briefly-disconnected replica needs WAL that was already removed and must be rebuilt.
- • Too high: extra WAL sits on disk even when replicas are healthy.
- • Replication slots are the more reliable mechanism, but need monitoring so they do not fill the disk.