wal_compression
Fact — official short description: “Compresses full-page writes written in WAL file with specified method.”
Identity
Lifecycle
| Fact | Value |
|---|---|
| First observed | PG9.5 |
| Present in | PG9.5–19 Beta 3 |
| Removed in | No |
| Introduction commit | 57aa5b2bb11a — Add GUC to enable compression of full page images stored in WAL. |
| Commit date | 2015-03-11 |
| Discussion | — |
Default history
| Versions | Raw boot_val |
Unit | Human value |
|---|---|---|---|
| PG9.5–19 Beta 3 | off |
— | off |
How it works
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
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. |
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 |
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
- 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
full_page_writes · wal_log_hints · wal_level · wal_buffers · commit_delay · commit_siblings