{"Entry":{"collection":"guc","key":"wal_compression","name":"wal_compression","aliases":[],"metadata":{"baseline":false,"boot_human":"Not specified","boot_val":null,"category":"Write-Ahead Log / Settings","category_zh":"","changed_in":["15"],"changes":[{"documentation_changed":false,"fields":{},"from":"9.4","status":"added","to":"9.5"},{"documentation_changed":true,"fields":{},"from":"12","status":"changed","to":"13"},{"documentation_changed":true,"fields":{},"from":"13","status":"changed","to":"14"},{"documentation_changed":true,"fields":{"enumvals":{"from":null,"to":["pglz","lz4","zstd","on","off"]},"short_desc":{"from":"Compresses full-page writes written in WAL file.","to":"Compresses full-page writes written in WAL file with specified method."},"vartype":{"from":"bool","to":"enum"}},"from":"14","status":"changed","to":"15"},{"documentation_changed":true,"fields":{},"from":"18","status":"changed","to":"19"}],"content_hash":"37920453beacd2e87bb5065524af000e478c5a70cb9b9a5c25a1c81ac79e40c8","context":"","default_changed_in":[],"default_history":[{"from":"9.5","to":"19","value":"off"}],"editorial":{"advice":{"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.","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.","small":"Start from safe defaults and set explicit alerts for limited disk capacity. Do not disable durability or break the recovery chain merely to save modest I/O."},"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."],"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."],"references":[{"title":"PostgreSQL 19 Beta 4: wal_compression","url":"https://www.postgresql.org/docs/19/runtime-config-wal.html#GUC-WAL-COMPRESSION"},{"title":"PostgreSQL 19 release notes","url":"https://www.postgresql.org/docs/19/release-19.html"}],"related":["full_page_writes","wal_log_hints","wal_level","wal_buffers","commit_delay","commit_siblings"],"summary":"wal_compression — Compresses full-page writes written in WAL file with specified method. Observed in PG9.5–19 Beta 4; its last measured boot default is off in PG19 Beta 4, with superuser context. This is a beta-snapshot fact and can change before PostgreSQL 19 GA."},"enumvals":[],"first_version":"9.5","group":"Write-Ahead Log","group_slug":"wal","imported_at":"2026-09-27T17:57:32.320685+08:00","intro_commit":{"authored_at":"2015-03-11T15:52:24+09:00","discussion":[],"hash":"57aa5b2bb11a4dbfdfc0f92370e0742ae5aa367b","subject":"Add GUC to enable compression of full page images stored in WAL.","url":"https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=57aa5b2bb11a4dbfdfc0f92370e0742ae5aa367b"},"key":"wal_compression","last_version":"20","max_val":"","min_val":"","name":"wal_compression","position":464,"present_in":["9.5","9.6","10","11","12","13","14","15","16","17","18","19","20"],"short_desc":"This parameter enables compression of WAL using the specified compression method.","short_desc_zh":"","source_rev":"english-manuals:9e23c4104f6adf05cbbf5ae0d323bba69e40f3ba3be1834d30852065b435e3c2","unit":"","vartype":"enum"}},"Definition":{"Collection":"guc","Key":"wal_compression","SourceDatabase":"center","Version":"18","SourceTable":"guc","SourceKey":"wal_compression","SourceRevision":"english-manuals:9e23c4104f6adf05cbbf5ae0d323bba69e40f3ba3be1834d30852065b435e3c2","Facts":{"boot_val":"off","category":"Write-Ahead Log / Settings","context":"superuser","description":"This parameter enables compression of WAL using the specified compression method. When enabled, the PostgreSQL server compresses full page images written to WAL (e.g. when full_page_writes is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. The supported methods are pglz, lz4 (if PostgreSQL was compiled with --with-lz4) and zstd (if PostgreSQL was compiled with --with-zstd). The value on is a historical spelling of pglz. The default value is off. Only superusers and users with the appropriate SET privilege can change this setting. Enabling compression can reduce the WAL volume without increasing the risk of unrecoverable data corruption, but at the cost of some extra CPU spent on the compression during WAL logging and on the decompression during WAL replay.","doc":{"anchor":"GUC-WAL-COMPRESSION","file":"runtime-config-wal.html","lang":"en","sha256":"d2646404a06e8f7ac655204b4f28c049ae8f3fd4f2272db080fcefa2c4af0763","slug":"18"},"documented":true,"enumvals":["pglz","lz4","zstd","on","off"],"extra_desc":null,"lang":"en","max_val":null,"metadata_version":"18","min_val":null,"name":"wal_compression","short_desc":"Compresses full-page writes written in WAL file with specified method.","source":"pg-settings-source-snapshot","unit":null,"vartype":"enum"},"ManualEvidence":{"doc":{"anchor":"GUC-WAL-COMPRESSION","file":"runtime-config-wal.html","lang":"en","sha256":"d2646404a06e8f7ac655204b4f28c049ae8f3fd4f2272db080fcefa2c4af0763","slug":"18"}},"MeasuredEvidence":{"metadata_version":"18"}},"Text":{"Collection":"guc","Key":"wal_compression","SourceDatabase":"pgweb","Version":"18","Locale":"zh-Hans","Title":"wal_compression","Summary":"","BodyHTML":"\u003cp\u003e此参数启用使用指定的压缩方法对WAL进行压缩。启用后，\u003cspan\u003ePostgreSQL\u003c/span\u003e服务器会压缩写入 WAL 的整页镜像，例如在启用\u003ca href=\"/docs/18/runtime-config-wal.html#GUC-FULL-PAGE-WRITES\" rel=\"nofollow\"\u003efull_page_writes\u003c/a\u003e时、基础备份期间等。在WAL重放期间，将对压缩的页镜像进行解压缩。支持的方法有\u003ccode\u003epglz\u003c/code\u003e、\u003ccode\u003elz4\u003c/code\u003e（如果\u003cspan\u003ePostgreSQL\u003c/span\u003e 使用\u003ccode\u003e--with-lz4\u003c/code\u003e编译）和 \u003ccode\u003ezstd\u003c/code\u003e（如果\u003cspan\u003ePostgreSQL\u003c/span\u003e 使用\u003ccode\u003e--with-zstd\u003c/code\u003e编译）。值 \u003ccode\u003eon\u003c/code\u003e 是 \u003ccode\u003epglz\u003c/code\u003e 的历史拼写。默认值为\u003ccode\u003eoff\u003c/code\u003e。只有超级用户和具有适当\u003ccode\u003eSET\u003c/code\u003e权限的用户才能更改此设置。\u003c/p\u003e\u003cp\u003e启用压缩可以减少 WAL 数据量，而且不会增加不可恢复的数据损坏风险；代价是在记录 WAL 时压缩、重放 WAL 时解压会额外消耗一些 CPU。\u003c/p\u003e","SourceRevision":"2026-09-11@29c86d9","ContentHash":"a2726ed24b7fa0e53f5da322b6f3068235c8b4aafcb3cfb5afbbe2db92dd0f51","Payload":{"carried_from":"","carry_reason":"","doc_html":"\u003cp\u003e此参数启用使用指定的压缩方法对WAL进行压缩。启用后，\u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e服务器会压缩写入 WAL 的整页镜像，例如在启用\u003ca href=\"/docs/18/runtime-config-wal.html#GUC-FULL-PAGE-WRITES\"\u003efull_page_writes\u003c/a\u003e时、基础备份期间等。在WAL重放期间，将对压缩的页镜像进行解压缩。支持的方法有\u003ccode class=\"literal\"\u003epglz\u003c/code\u003e、\u003ccode class=\"literal\"\u003elz4\u003c/code\u003e（如果\u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e 使用\u003ccode class=\"option\"\u003e--with-lz4\u003c/code\u003e编译）和 \u003ccode class=\"literal\"\u003ezstd\u003c/code\u003e（如果\u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e 使用\u003ccode class=\"option\"\u003e--with-zstd\u003c/code\u003e编译）。值 \u003ccode class=\"literal\"\u003eon\u003c/code\u003e 是 \u003ccode class=\"literal\"\u003epglz\u003c/code\u003e 的历史拼写。默认值为\u003ccode class=\"literal\"\u003eoff\u003c/code\u003e。只有超级用户和具有适当\u003ccode class=\"literal\"\u003eSET\u003c/code\u003e权限的用户才能更改此设置。\u003c/p\u003e\u003cp\u003e启用压缩可以减少 WAL 数据量，而且不会增加不可恢复的数据损坏风险；代价是在记录 WAL 时压缩、重放 WAL 时解压会额外消耗一些 CPU。\u003c/p\u003e","doc_same_as":""}},"RequestedLocale":"zh-Hans","Fallback":false,"Versions":["10","11","12","13","14","15","16","17","18","19","20","9.5","9.6"],"Locales":["en","zh-Hans"],"Signatures":null,"Spellings":null,"SQLState":null,"Evidence":null}
