Parameter · Write-Ahead Log / Settings
wal_init_zero
Writes zeroes to new WAL files before first use.
- Default:
on - Type: bool
- Applies: Session (superuser)
In plain words
When PostgreSQL needs a brand-new WAL segment file (16 MB), it normally writes it full of zeroes first so the space is really allocated. On copy-on-write file systems such as ZFS or Btrfs that work is wasted, and off just writes the last byte to set the file size.
For DBAs and operators
Zero-filling guarantees the file system allocated all blocks before WAL is written into them, so later WAL writes never fail with "no space" mid-segment and do not need metadata updates on every write. On COW file systems every write allocates new blocks anyway, so pre-zeroing only doubles the I/O.
- Only new segments are affected. Recycled segments (see wal_recycle) are reused as-is.
- Segment creation shows up in PostgreSQL 18
pg_stat_ioasobject = 'wal', context = 'init'; heavy creation suggestsmin_wal_sizeis too small for bursts. - Typical ZFS advice:
wal_init_zero = offandwal_recycle = off. On ext4/XFS keep both on.
How to change it
A superuser (or a role granted SET) can change it per session with SET.