From: | Nikolay Samokhvalov <nik(at)postgres(dot)ai> |
---|---|
To: | pgsql-hackers mailing list <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Support specifying compression level in wal_compression |
Date: | 2025-05-27 09:08:53 |
Message-ID: | CAM527d_pLB8v2atHRqBK9+cffUf5bGVFL1n0O2uNtsZyzyn2pw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
I thought it makes sense to extend wal_compression to support compression
levels.
The patch replaces the simple enum-based setting with string-based
'method[:level]' syntax, similar to the --compress option in pg_dump.
What's inside:
- Unified GUC design: wal_compression = 'method[:level]'
- Supported formats: 'off', 'on', 'pglz', 'lz4[:level]', 'zstd[:level]'
- Algorithm-specific defaults: LZ4 defaults to level 1, ZSTD to level 3
when no level is specified.
- Parameter validation is performed at SET time.
- The string is parsed only once during GUC assignment.
- Backward compatibility for common settings: While the GUC type changes
from enum to string, common previous boolean-like string values (e.g.,
'off', 'true', '0') are handled, mapping to 'pglz' or 'off' correspondingly.
- Includes docs change proposal, as well extensive new regression and TAP
tests.
Additionally, it adds LZ4HC support -- for LZ4, if levels 10-12 are
specified, then, when available (checked at build time + runtime), it's
supposed to use LZ4HC for higher compression ratio. This part needs
additional testing.
Originally, I considered adding wal_compression_level but eventually
decided to exten wal_compression, because of two reasons:
1. with a separate param, a question of defaults needs to be solved, and I
didn't find an elegant solution;
2. "method:level" syntax is already used in another place – pg_dump
An early version of this patch was reviewed by Andrey Borodin off-list, and
it was extremely helpful.
looking forward to seeing feedback
Nik
Attachment | Content-Type | Size |
---|---|---|
001_wal_compression_with_levels_and_lz4hc.patch | application/octet-stream | 38.5 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Alexander Korotkov | 2025-05-27 09:12:41 | Re: Slot's restart_lsn may point to removed WAL segment after hard restart unexpectedly |
Previous Message | Yugo Nagata | 2025-05-27 08:52:40 | Re: Prevent internal error at concurrent CREATE OR REPLACE FUNCTION |