wal_compression
Compress full-page images written to the WAL.
- Predeterminado
off- Range
- off, on (pglz), pglz, lz4, zstd
- Restart needed
- No
- Default checked on
- PostgreSQL 18
Lo que hace
Full-page writes are often most of the WAL volume after a checkpoint. Compressing them trades CPU for less WAL, less replication traffic and smaller archives. lz4 and zstd are available from PostgreSQL 15 if the server was built with them.
Valor predeterminado
off. off (PostgreSQL 18).
Check the current value
SHOW wal_compression; SELECT setting, unit, boot_val, context, source, pending_restart FROM pg_settings WHERE name = 'wal_compression';
Change it
SET wal_compression = lz4; -- this session ALTER SYSTEM SET wal_compression = lz4; SELECT pg_reload_conf();
No restart. Superusers, or roles granted SET on the parameter (PostgreSQL 15 and later), can SET it per session; a server-wide ALTER SYSTEM change applies after a reload (context is superuser).
When to change it
On write-heavy servers where WAL volume, replication lag or archive size is a problem; lz4 costs little CPU.
What can go wrong
Extra CPU on every full-page write.
Questions about wal_compression
What is the default value of wal_compression in PostgreSQL?
off. off (PostgreSQL 18).
Does changing wal_compression require a restart?
No. No restart. Superusers, or roles granted SET on the parameter (PostgreSQL 15 and later), can SET it per session; a server-wide ALTER SYSTEM change applies after a reload (context is superuser).
When should I change wal_compression?
On write-heavy servers where WAL volume, replication lag or archive size is a problem; lz4 costs little CPU.
Back to all PostgreSQL settings, or check the PostgreSQL manual for every option.
Check wal_compression on your own server
SQLly runs the query above against PostgreSQL and the other engines in this reference, from one desktop app on macOS, Windows and Linux.