max_wal_size
Read PG 18 manual ↗Maximum size to let the WAL grow during automatic checkpoints.
- Type
- integer
- Context
- sighup
- Measured default
- 1 GiB
- Unit
- MB
- Metadata snapshot
- 18
Definition PG 18 manual
Maximum size to let the WAL grow during automatic checkpoints. This is a soft limit; WAL size can exceed max_wal_size under special circumstances, such as heavy load, a failing archive_command or archive_library, or a high wal_keep_size setting. If this value is specified without units, it is taken as megabytes. The default is 1 GB. Increasing this parameter can increase the amount of time needed for crash recovery. This parameter can only be set in the postgresql.conf file or on the server command line.
Measured default history
| Version interval | Default |
|---|---|
| 9.5 – 9.6 | 1 GiB (64 × 16MB) |
| 10 – 19 | 1 GiB |
Authored guidance from the GUC source snapshot; the version-specific manual above is the definition reference. View source ↗
How it works
The checkpointer starts an automatic checkpoint when checkpoint_timeout expires or when WAL growth is about to exceed max_wal_size, whichever happens first. More frequent checkpoints write dirty buffers more often and also cause more full-page images after each checkpoint.
max_wal_size is not a disk quota. WAL can exceed it under heavy write load, during recovery, when archiving is slow or failing, when wal_keep_size retains files, or when a replication slot still needs old WAL.
A larger value usually reduces requested checkpoints and checkpoint-related write churn, but reserves a longer WAL replay horizon after a crash and requires more pg_wal headroom. min_wal_size controls the lower recycling floor; it does not turn max_wal_size into a hard ceiling.
Operational considerations
Treating max_wal_size as a hard cap on pg_wal usage.
Raising it to conceal a failed archiver or an abandoned replication slot.
Lowering it without checking full-page-image volume and checkpoint latency.
Ignoring that a bare numeric value is interpreted in megabytes.
Tuning it independently of checkpoint_timeout and checkpoint_completion_target.
Workload guidance
OLAP: Bulk loads and large maintenance jobs can generate WAL in bursts, so a larger value can avoid checkpoint storms. Confirm that pg_wal capacity and archive throughput can absorb the burst and that the longer crash-recovery window is acceptable.
OLTP: Size it from measured peak WAL generation and an acceptable checkpoint cadence. Watch pg_stat_checkpointer, checkpoint warnings, write latency, archive lag, and free space; raise it when requested checkpoints are persistently dominant, not merely because a generic formula says so.
SMALL: Keep a conservative bounded value on small disks. Account separately for slot retention and archive backlog, and leave emergency free space rather than assigning most of the volume to the nominal checkpoint threshold.
Version history 5
- PG 14 → 15changed
- PG 12 → 13changed
- PG 11 → 12changed
- PG 9.6 → 10changed
- PG 9.4 → 9.5added
Related entries
Further reading
Definition snapshot: english-manuals:edef7e09e42b6482c7025906ac3… · English manual source