DB Internals AtlasPostgreSQL 18.6 Home About

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_io as object = 'wal', context = 'init'; heavy creation suggests min_wal_size is too small for bursts.
  • Typical ZFS advice: wal_init_zero = off and wal_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.

See it in context

Write-ahead log (WAL) Physical layout on disk

Related parameters

wal_recycle min_wal_size max_wal_size wal_sync_method

All Write-Ahead Log parameters