wal_init_zero
Read PG 18 manual ↗If set to on (the default), this option causes new WAL files to be filled with zeroes.
- Type
- bool
- Context
- superuser
- Measured default
- on
- Unit
- —
- Metadata snapshot
- 18
Definition PG 18 manual
If set to on (the default), this option causes new WAL files to be filled with zeroes. On some file systems, this ensures that space is allocated before we need to write WAL records. However, Copy-On-Write (COW) file systems may not benefit from this technique, so the option is given to skip the unnecessary work. If set to off, only the final byte is written when the file is created so that it has the expected size.
Measured default history
| Version interval | Default |
|---|---|
| 12 – 19 | on |
Authored guidance from the GUC source snapshot; the version-specific manual above is the definition reference. View source ↗
How it works
Writes zeroes to new WAL files before first use. A superuser or a role granted SET privilege can change it for the relevant session or configuration scope.
With on, newly created WAL segments are zero-filled, which preallocates blocks on many filesystems. Copy-on-write filesystems may turn that work into unnecessary allocation and fragmentation; off still creates a correctly sized file by writing its last byte.
Monitor and change wal_init_zero together with wal_recycle, wal_segment_size, min_wal_size. Validate on the relevant server role and real workload, then use its superuser context to choose session change, reload, or restart; a historical boot default is not the current effective value.
Operational considerations
Disabling zero-fill on a conventional filesystem and moving allocation stalls into peak WAL creation.
Keeping zero-fill on copy-on-write storage without measuring allocation and fragmentation cost.
Assuming an apparently sparse file means PostgreSQL changed wal_segment_size.
Changing a session value and expecting already-created WAL segments to be rewritten.
Workload guidance
OLAP: Provision WAL, archive bandwidth, and recovery I/O for bulk-load peaks. Coordinate load pacing and checkpoints when reducing spikes; never break the recovery chain for throughput.
OLTP: Establish durability and recovery objectives first, then tune wal_init_zero from WAL rate, flush latency, checkpoints, and peak pg_wal usage. Validate every change with crash/recovery and archive monitoring.
SMALL: Start from safe defaults and set explicit alerts for limited disk capacity. Do not disable durability or break the recovery chain merely to save modest I/O.
Version history 1
- PG 11 → 12added
Related entries
Further reading
Definition snapshot: english-manuals:0542129cfaf4827a8e9ff82340f… · English manual source