{
  "slug": "wal-compression",
  "term": "WAL compression",
  "aliases": [
    "wal_compression",
    "PostgreSQL WAL image compression"
  ],
  "definition": "PostgreSQL WAL compression optionally compresses full-page images within its write-ahead log.",
  "note": "The setting targets page images, not all WAL records or archived segment files. PostgreSQL 18 supports pglz, plus lz4 and zstd when compiled with the corresponding libraries. Replay decompresses the images. [pg-settings]\n\nThe REL_18_0 builder can omit an unused page hole and uses compression only when the encoded representation saves space. An image count is therefore not a byte count. [pg-image-code]",
  "status": "shipping",
  "advantages": [],
  "limitations": [
    {
      "text": "Compression and decompression consume CPU during logging and replay.",
      "citationIds": [
        "pg-settings"
      ]
    }
  ],
  "supersedes": [],
  "supersededBy": [],
  "firstSeen": null,
  "lastSeen": null,
  "related": [
    "full-page-write",
    "write-ahead-log",
    "database-checkpoint"
  ],
  "citations": [
    {
      "id": "pg-settings",
      "title": "PostgreSQL 18: WAL settings, hint logging and image compression",
      "url": "https://www.postgresql.org/docs/18/runtime-config-wal.html",
      "accessed": "2026-10-16"
    },
    {
      "id": "pg-image-code",
      "title": "PostgreSQL REL_18_0: xloginsert.c, page holes and XLogCompressBackupBlock",
      "url": "https://github.com/postgres/postgres/blob/REL_18_0/src/backend/access/transam/xloginsert.c",
      "accessed": "2026-10-16"
    },
    {
      "id": "hesela-wal",
      "title": "Hesela: WAL page images, hint-bit changes and measurement boundaries",
      "url": "https://hesela.com/analyses/wal-checkpoints-torn-pages/#pg-page-images",
      "accessed": "2026-10-16"
    }
  ],
  "provenance": [
    "Scoped to PostgreSQL 18 documentation and REL_18_0 code; no measured compression ratio or performance improvement is claimed."
  ],
  "updated": "2026-10-16"
}
