# wal_compression

> wal_compression — Compresses full-page writes written in WAL file with specified method. Observed in PG9.5–19 Beta 3; its last measured boot default is off in PG19 Beta 3, with superuser context. This is a beta-snapshot fact and can change before PostgreSQL 19 GA.
---

> [!NOTE]
> **Fact — official short description:** “Compresses full-page writes written in WAL file with specified method.”

## Identity {#identity}

| Field | Value | Meaning |
| --- | --- | --- |
| Type | `enum` | 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 | `pglz`, `lz4`, `zstd`, `on`, `off` | — for non-enum types |
| Category | Write-Ahead Log / Settings | Upstream classification |
| Latest boot value | `off` | off |
{.fields meta="-"}

## Lifecycle {#lifecycle}

| Fact | Value |
| --- | --- |
| First observed | PG9.5 |
| Present in | PG9.5–19 Beta 3 |
| Removed in | No |
| Introduction commit | [`57aa5b2bb11a`](https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=57aa5b2bb11a4dbfdfc0f92370e0742ae5aa367b) — Add GUC to enable compression of full page images stored in WAL. |
| Commit date | 2015-03-11 |
| Discussion | — |

## Default history {#default-history}

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

## How it works {#mechanism}

Compresses full-page writes written in WAL file with specified method. A superuser or a role granted SET privilege can change it for the relevant session or configuration scope.

Compression applies to full-page images produced by full_page_writes, backup, or hint logging, not to every WAL record. pglz is built in; lz4/zstd availability depends on the build, and replay pays decompression CPU in exchange for lower WAL volume.

Monitor and change wal_compression together with full_page_writes, wal_log_hints, wal_level. 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_compression 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 | `lz4` | different | `lz4` |
| OLAP | `lz4` | different | `lz4` |
| CRIT | `lz4` | different | `lz4` |
| TINY | `lz4` | different | `lz4` |
{.full-width}

> [!CAUTION]
> **Advice — pending human review.** Fact from the current Pigsty template projection: OLTP: PG9.5–14 unmodified, PG15–19 Beta 3 = lz4 (dcs); OLAP: PG9.5–14 unmodified, PG15–19 Beta 3 = lz4 (dcs); CRIT: PG9.5–14 unmodified, PG15–19 Beta 3 = lz4 (dcs); TINY: PG9.5–14 unmodified, PG15–19 Beta 3 = lz4 (dcs). Advice, pending human review — Editorial interpretation, pending human maintainer review: the override appears intended to reduce full-page-image WAL volume with LZ4 on releases that support the enum method; confirm it against the current Pigsty templates, hardware fixture, and operational guarantees before publication.

## Common pitfalls {#common-pitfalls}

- Expecting compression to affect every WAL record rather than full-page images.
- Selecting lz4 or zstd on a server build that does not provide that method.
- Ignoring compression CPU on the primary and decompression CPU during replay.
- Changing a privileged session value and assuming other sessions or future connections inherited it.
- Comparing WAL bytes without controlling checkpoint frequency and full_page_writes activity.

## Related parameters {#related-parameters}

[`full_page_writes`](/parameters/full-page-writes/) · [`wal_log_hints`](/parameters/wal-log-hints/) · [`wal_level`](/parameters/wal-level/) · [`wal_buffers`](/parameters/wal-buffers/) · [`commit_delay`](/parameters/commit-delay/) · [`commit_siblings`](/parameters/commit-siblings/)

## References {#references}

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