If set to on (the default), this option causes new WAL files to be filled with zeroes.
At a glance
| Property | Value |
|---|---|
| Parameter | wal_init_zero |
| Category | Write Ahead Log |
| Default | on |
| Value type | boolean (on/off) |
| Change scope | Per-session (SET) |
| Available in | PostgreSQL 12, 13, 14, 15, 16, 17, 18, 19 (added in 12) |
What it does
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.
(Description quoted from the official PostgreSQL documentation.)
How to apply a change
Can be set per session with SET, per role/database with ALTER ROLE/DATABASE ... SET, or globally in postgresql.conf.
Inspect the current value and source with SHOW wal_init_zero; or SELECT name, setting, unit, context, source FROM pg_settings WHERE name = 'wal_init_zero';.
Tuning guidance
Leave it on so new WAL files are zero-filled for reliable space reservation; turn it off only on filesystems where preallocation is wasteful and you accept the trade-off.