# wal_decode_buffer_size

> wal_decode_buffer_size sets the buffer size for reading ahead in the WAL during recovery. It is a postmaster setting present in PG15–18; the latest recorded boot default is 512 KiB.
---

> [!NOTE]
> **Fact — official short description:** “Buffer size for reading ahead in the WAL during recovery.”

## Identity {#identity}

| Field | Value | Meaning |
| --- | --- | --- |
| Type | `integer` | Upstream pg_settings type |
| Context | `postmaster` | Requires a server restart |
| Unit | `B` | Raw unit |
| Range | `65536` – `1073741823` | Raw limits in the last observed version |
| Enum values | — | — for non-enum types |
| Category | Write-Ahead Log / Recovery | Upstream classification |
| Latest boot value | `524288` | 512 KiB |
{.fields meta="-"}

## Lifecycle {#lifecycle}

| Fact | Value |
| --- | --- |
| First observed | PG15 |
| Present in | PG15–19 Beta 3 |
| Removed in | No |
| Introduction commit | [`1d257577e08d`](https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=1d257577e08d3e598011d6850fd1025858de8c8c) — Optionally prefetch referenced data in recovery. |
| Commit date | 2021-04-08 |
| Discussion | [thread 1](https://postgr.es/m/CA%2BhUKGJ4VJN8ttxScUFM8dOKX0BrBiboo5uz1cq%3DAovOddfHpA%40mail.gmail.com) |

## Default history {#default-history}

| Versions | Raw `boot_val` | Unit | Human value |
| --- | --- | --- | --- |
| PG15–19 Beta 3 | `524288` | `B` | 512 KiB |
{.full-width caption="Measured PG9.0–19 Beta 3 boot defaults"}

## How it works {#mechanism}

Buffer size for reading ahead in the WAL during recovery. The value is fixed when the server starts, so changing it requires a restart.

Recovery scans this far ahead in decoded WAL to discover future block references for prefetch. It is a restart-time memory/lead limit, not a logical-decoding output buffer, and only helps when recovery_prefetch and the storage workload benefit.

Monitor and change wal_decode_buffer_size together with recovery_prefetch, maintenance_io_concurrency, effective_io_concurrency. Validate on the relevant server role and real workload, then use its postmaster 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 | Tune wal_decode_buffer_size with recovery/standby catch-up benchmarks on production-like storage while observing replay I/O wait, cache behavior, and maintenance_io_concurrency. Keep the default without measured benefit. |
| OLAP | Large data with slow random reads may benefit more, but excess prefetch competes with query I/O and cache. Test crash recovery and a query-serving standby separately. |
| Small nodes | The default is usually sufficient. Do not spend scarce memory or I/O queue depth on a larger look-ahead window unless a recovery-time objective is demonstrably missed. |
{.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: PG15–19 Beta 3 unmodified; OLAP: PG15–19 Beta 3 unmodified; CRIT: PG15–19 Beta 3 unmodified; TINY: PG15–19 Beta 3 unmodified. No Pigsty-specific rationale is inferred from an absent override.

## Common pitfalls {#common-pitfalls}

- Confusing pg_settings base units with human-readable configuration units.
- Benchmarking throughput without a crash-recovery and archive-restore test.
- Ignoring interactions with checkpoints, replication slots, or archive failure.
- Reloading a restart-context value and assuming it became active.

## Related parameters {#related-parameters}

[`recovery_prefetch`](/parameters/recovery-prefetch/) · [`maintenance_io_concurrency`](/parameters/maintenance-io-concurrency/) · [`effective_io_concurrency`](/parameters/effective-io-concurrency/) · [`shared_buffers`](/parameters/shared-buffers/) · [`archive_cleanup_command`](/parameters/archive-cleanup-command/) · [`archive_command`](/parameters/archive-command/)

## References {#references}

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