Parameter · Write-Ahead Log / Checkpoints
min_wal_size
Sets the minimum size to shrink the WAL to.
- Default:
80MB - Type: integer (MB)
- Range: 2MB … max (2147483647)
- Applies: Reload
In plain words
After a checkpoint, old WAL files are either deleted or kept to be reused later. As long as pg_wal is smaller than min_wal_size, old files are always kept and recycled. This avoids creating new files when a burst of writes comes in.
For DBAs and operators
At the end of each checkpoint, PostgreSQL estimates how much WAL the next cycle will need (from a moving average of checkpoint distances, the estimate= field in the log) and keeps that many recycled segments, clamped between min_wal_size and max_wal_size. Anything beyond is removed. So after a quiet period pg_wal shrinks, but never below min_wal_size.
- Raise it if checkpoint logs during bursts show many
WAL file(s) added: creating and zero-filling 16 MB files costs I/O at the worst moment (see wal_init_zero). - It is not a reservation: it does not pre-create files, and WAL that is still needed is never governed by it.
- Default 80 MB (5 segments); must be at least twice the WAL segment size.
How to change it
Change in postgresql.conf or ALTER SYSTEM, then run SELECT pg_reload_conf().