# wal_init_zero

> wal_init_zero writes zeroes to new WAL files before first use. It is a superuser setting present in PG12–18; the latest recorded boot default is on.
---

> [!NOTE]
> **Fact — official short description:** “Writes zeroes to new WAL files before first use.”

## Identity {#identity}

| Field | Value | Meaning |
| --- | --- | --- |
| Type | `bool` | Upstream pg_settings type |
| Context | `superuser` | Settable at runtime by a superuser |
| Unit | — | Raw unit |
| Range | — | Raw limits in the last observed version |
| Enum values | — | — for non-enum types |
| Category | Write-Ahead Log / Settings | Upstream classification |
| Latest boot value | `on` | on |
{.fields meta="-"}

## Lifecycle {#lifecycle}

| Fact | Value |
| --- | --- |
| First observed | PG12 |
| Present in | PG12–19 Beta 3 |
| Removed in | No |
| Introduction commit | [`475861b2615d`](https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=475861b2615dd63ae8431d811749a6f9a15bbfd6) — Add wal_recycle and wal_init_zero GUCs. |
| Commit date | 2019-04-02 |
| Discussion | [thread 1](https://postgr.es/m/CACPQ5Fo00QR7LNAcd1ZjgoBi4y97%2BK760YABs0vQHH5dLdkkMA%40mail.gmail.com) |

## Default history {#default-history}

| Versions | Raw `boot_val` | Unit | Human value |
| --- | --- | --- | --- |
| PG12–19 Beta 3 | `on` | — | on |
{.full-width caption="Measured PG9.0–19 Beta 3 boot defaults"}

## How it works {#mechanism}

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.

## Tuning advice {#tuning-advice}

> [!TIP]
> **Advice.** These are workload-specific starting points and must be validated with measurements.

| Workload | Guidance |
| --- | --- |
| 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. |
| 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. |
| Small nodes | Start from safe defaults or the measured Pigsty value and set explicit alerts for limited disk capacity. Do not disable durability or break the recovery chain merely to save modest I/O. |
{.full-width}

## Pigsty {#pigsty}

Values use the fixed 8-vCPU, 32-GiB, 100-GiB SSD fixture and render the current Pigsty templates for PG19 Beta 3; this does not assert current Pigsty support for that historical or beta release.

| Template | Effective value | Versus upstream boot | Source expression |
| --- | --- | --- | --- |
| OLTP | Unmodified | — | — |
| OLAP | Unmodified | — | — |
| CRIT | Unmodified | — | — |
| TINY | Unmodified | — | — |
{.full-width}

> [!CAUTION]
> **Advice — pending human review.** Fact from the current Pigsty template projection: OLTP: PG12–19 Beta 3 unmodified; OLAP: PG12–19 Beta 3 unmodified; CRIT: PG12–19 Beta 3 unmodified; TINY: PG12–19 Beta 3 unmodified. No Pigsty-specific rationale is inferred from an absent override.

## Common pitfalls {#common-pitfalls}

- 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.

## Related parameters {#related-parameters}

[`wal_recycle`](/parameters/wal-recycle/) · [`wal_segment_size`](/parameters/wal-segment-size/) · [`min_wal_size`](/parameters/min-wal-size/) · [`max_wal_size`](/parameters/max-wal-size/) · [`commit_delay`](/parameters/commit-delay/) · [`commit_siblings`](/parameters/commit-siblings/)

## References {#references}

- [PostgreSQL 19 Beta 3 — wal_init_zero](https://www.postgresql.org/docs/19/runtime-config-wal.html#GUC-WAL-INIT-ZERO)
- [PostgreSQL 19 release notes](https://www.postgresql.org/docs/19/release-19.html)
- [Machine-readable GUC export](/data/guc.jsonl)
