agora inbox for pgsql-hackers@postgresql.orghelp / color / mirror / Atom feed
[PATCH v2.12 13/28] Enable IO concurrency on all systems 333+ messages / 2 participants [nested] [flat]
* [PATCH v2.12 13/28] Enable IO concurrency on all systems @ 2025-03-19 14:15 Andres Freund <andres@anarazel.de> 0 siblings, 0 replies; 333+ messages in thread From: Andres Freund @ 2025-03-19 14:15 UTC (permalink / raw) Previously effective_io_concurrency and maintenance_io_concurrency could not be set above 0 on machines without fadvise support. AIO enables IO concurrency without such support. Currently only subsystems using the read stream API will take advantage of this. Other users of maintenance_io_concurrency (like recovery prefetching) which leverage OS advice directly will not benefit from this change. In those cases, maintenance_io_concurrency will have no effect on I/O behavior. Author: Melanie Plageman <melanieplageman@gmail.com> Discussion: https://postgr.es/m/CAAKRu_atGgZePo=_g6T3cNtfMf0QxpvoUh5OUqa_cnPdhLd=gw@mail.gmail.com --- src/include/storage/bufmgr.h | 6 ---- src/include/utils/guc_hooks.h | 4 --- src/backend/access/common/reloptions.c | 8 ----- src/backend/commands/variable.c | 30 ------------------- src/backend/utils/misc/guc_tables.c | 4 +-- src/backend/utils/misc/postgresql.conf.sample | 6 ++-- src/bin/initdb/initdb.c | 5 ---- doc/src/sgml/config.sgml | 15 +++++----- doc/src/sgml/ref/alter_tablespace.sgml | 2 +- doc/src/sgml/ref/create_tablespace.sgml | 2 +- 10 files changed, 14 insertions(+), 68 deletions(-) diff --git a/src/include/storage/bufmgr.h b/src/include/storage/bufmgr.h index 7abb3bdfd9d..784df8b00cb 100644 --- a/src/include/storage/bufmgr.h +++ b/src/include/storage/bufmgr.h @@ -156,14 +156,8 @@ extern PGDLLIMPORT int bgwriter_lru_maxpages; extern PGDLLIMPORT double bgwriter_lru_multiplier; extern PGDLLIMPORT bool track_io_timing; -/* only applicable when prefetching is available */ -#ifdef USE_PREFETCH #define DEFAULT_EFFECTIVE_IO_CONCURRENCY 16 #define DEFAULT_MAINTENANCE_IO_CONCURRENCY 16 -#else -#define DEFAULT_EFFECTIVE_IO_CONCURRENCY 0 -#define DEFAULT_MAINTENANCE_IO_CONCURRENCY 0 -#endif extern PGDLLIMPORT int effective_io_concurrency; extern PGDLLIMPORT int maintenance_io_concurrency; diff --git a/src/include/utils/guc_hooks.h b/src/include/utils/guc_hooks.h index 0f1e74f96c9..799fa7ace68 100644 --- a/src/include/utils/guc_hooks.h +++ b/src/include/utils/guc_hooks.h @@ -61,8 +61,6 @@ extern bool check_default_text_search_config(char **newval, void **extra, GucSou extern void assign_default_text_search_config(const char *newval, void *extra); extern bool check_default_with_oids(bool *newval, void **extra, GucSource source); -extern bool check_effective_io_concurrency(int *newval, void **extra, - GucSource source); extern bool check_huge_page_size(int *newval, void **extra, GucSource source); extern void assign_io_method(int newval, void *extra); extern bool check_io_max_concurrency(int *newval, void **extra, GucSource source); @@ -83,8 +81,6 @@ extern bool check_log_stats(bool *newval, void **extra, GucSource source); extern bool check_log_timezone(char **newval, void **extra, GucSource source); extern void assign_log_timezone(const char *newval, void *extra); extern const char *show_log_timezone(void); -extern bool check_maintenance_io_concurrency(int *newval, void **extra, - GucSource source); extern void assign_maintenance_io_concurrency(int newval, void *extra); extern void assign_io_max_combine_limit(int newval, void *extra); extern void assign_io_combine_limit(int newval, void *extra); diff --git a/src/backend/access/common/reloptions.c b/src/backend/access/common/reloptions.c index 645b5c00467..46c1dce222d 100644 --- a/src/backend/access/common/reloptions.c +++ b/src/backend/access/common/reloptions.c @@ -361,11 +361,7 @@ static relopt_int intRelOpts[] = RELOPT_KIND_TABLESPACE, ShareUpdateExclusiveLock }, -#ifdef USE_PREFETCH -1, 0, MAX_IO_CONCURRENCY -#else - 0, 0, 0 -#endif }, { { @@ -374,11 +370,7 @@ static relopt_int intRelOpts[] = RELOPT_KIND_TABLESPACE, ShareUpdateExclusiveLock }, -#ifdef USE_PREFETCH -1, 0, MAX_IO_CONCURRENCY -#else - 0, 0, 0 -#endif }, { { diff --git a/src/backend/commands/variable.c b/src/backend/commands/variable.c index f550a3c0c63..d3567aa7f27 100644 --- a/src/backend/commands/variable.c +++ b/src/backend/commands/variable.c @@ -1145,7 +1145,6 @@ check_cluster_name(char **newval, void **extra, GucSource source) void assign_maintenance_io_concurrency(int newval, void *extra) { -#ifdef USE_PREFETCH /* * Reconfigure recovery prefetching, because a setting it depends on * changed. @@ -1153,7 +1152,6 @@ assign_maintenance_io_concurrency(int newval, void *extra) maintenance_io_concurrency = newval; if (AmStartupProcess()) XLogPrefetchReconfigure(); -#endif } /* @@ -1249,34 +1247,6 @@ check_default_with_oids(bool *newval, void **extra, GucSource source) return true; } -bool -check_effective_io_concurrency(int *newval, void **extra, GucSource source) -{ -#ifndef USE_PREFETCH - if (*newval != 0) - { - GUC_check_errdetail("\"%s\" must be set to 0 on platforms that lack support for issuing read-ahead advice.", - "effective_io_concurrency"); - return false; - } -#endif /* USE_PREFETCH */ - return true; -} - -bool -check_maintenance_io_concurrency(int *newval, void **extra, GucSource source) -{ -#ifndef USE_PREFETCH - if (*newval != 0) - { - GUC_check_errdetail("\"%s\" must be set to 0 on platforms that lack support for issuing read-ahead advice.", - "maintenance_io_concurrency"); - return false; - } -#endif /* USE_PREFETCH */ - return true; -} - bool check_ssl(bool *newval, void **extra, GucSource source) { diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 989825d3a9c..5d729102f46 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -3245,7 +3245,7 @@ struct config_int ConfigureNamesInt[] = &effective_io_concurrency, DEFAULT_EFFECTIVE_IO_CONCURRENCY, 0, MAX_IO_CONCURRENCY, - check_effective_io_concurrency, NULL, NULL + NULL, NULL, NULL }, { @@ -3259,7 +3259,7 @@ struct config_int ConfigureNamesInt[] = &maintenance_io_concurrency, DEFAULT_MAINTENANCE_IO_CONCURRENCY, 0, MAX_IO_CONCURRENCY, - check_maintenance_io_concurrency, assign_maintenance_io_concurrency, + NULL, assign_maintenance_io_concurrency, NULL }, diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 2246ccb85a7..771fe4cbe35 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -198,11 +198,11 @@ # - I/O - #backend_flush_after = 0 # measured in pages, 0 disables -#effective_io_concurrency = 16 # 1-1000; 0 disables prefetching -#maintenance_io_concurrency = 16 # 1-1000; 0 disables prefetching +#effective_io_concurrency = 16 # 1-1000; 0 disables issuing multiple simultaneous IO requests +#maintenance_io_concurrency = 16 # 1-1000; same as effective_io_concurrency #io_max_combine_limit = 128kB # usually 1-128 blocks (depends on OS) # (change requires restart) -#io_combine_limit = 128kB # usually 1-128 blocks (depends on OS) +#io_combine_limit = 128kB # usually 1-32 blocks (depends on OS) #io_method = worker # worker, io_uring, sync # (change requires restart) diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c index 21a0fe3ecd9..b9d75799ee0 100644 --- a/src/bin/initdb/initdb.c +++ b/src/bin/initdb/initdb.c @@ -1401,11 +1401,6 @@ setup_config(void) repltok, true); #endif -#ifndef USE_PREFETCH - conflines = replace_guc_value(conflines, "effective_io_concurrency", - "0", true); -#endif - #ifdef WIN32 conflines = replace_guc_value(conflines, "update_process_title", "off", true); diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index 13773c05ff4..e447ade5c2b 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -2585,8 +2585,7 @@ include_dir 'conf.d' session attempts to initiate in parallel. The allowed range is <literal>1</literal> to <literal>1000</literal>, or <literal>0</literal> to disable issuance of asynchronous I/O requests. - The default is <literal>16</literal> on supported systems, otherwise - <literal>0</literal>. + The default is <literal>16</literal>. </para> <para> @@ -2597,8 +2596,8 @@ include_dir 'conf.d' </para> <para> - On systems without prefetch advice support, attempting to configure - any value other than <literal>0</literal> will error out. + On systems with prefetch advice support, + <varname>effective_io_concurrency</varname> also controls the prefetch distance. </para> <para> @@ -2621,10 +2620,10 @@ include_dir 'conf.d' for maintenance work that is done on behalf of many client sessions. </para> <para> - The default is <literal>16</literal> on supported systems, otherwise - <literal>0</literal>. This value can be overridden for tables in a - particular tablespace by setting the tablespace parameter of the same - name (see <xref linkend="sql-altertablespace"/>). + The default is <literal>16</literal>. This value can be overridden + for tables in a particular tablespace by setting the tablespace + parameter of the same name (see <xref + linkend="sql-altertablespace"/>). </para> </listitem> </varlistentry> diff --git a/doc/src/sgml/ref/alter_tablespace.sgml b/doc/src/sgml/ref/alter_tablespace.sgml index 6ec863400d1..d0e08089ddb 100644 --- a/doc/src/sgml/ref/alter_tablespace.sgml +++ b/doc/src/sgml/ref/alter_tablespace.sgml @@ -88,7 +88,7 @@ ALTER TABLESPACE <replaceable>name</replaceable> RESET ( <replaceable class="par and <varname>maintenance_io_concurrency</varname>. Setting these values for a particular tablespace will override the planner's usual estimate of the cost of reading pages from tables in - that tablespace, and the executor's prefetching behavior, as established + that tablespace, and how many concurrent I/Os are issued, as established by the configuration parameters of the same name (see <xref linkend="guc-seq-page-cost"/>, <xref linkend="guc-random-page-cost"/>, diff --git a/doc/src/sgml/ref/create_tablespace.sgml b/doc/src/sgml/ref/create_tablespace.sgml index 9d5ab025261..b77e774c53f 100644 --- a/doc/src/sgml/ref/create_tablespace.sgml +++ b/doc/src/sgml/ref/create_tablespace.sgml @@ -110,7 +110,7 @@ CREATE TABLESPACE <replaceable class="parameter">tablespace_name</replaceable> and <varname>maintenance_io_concurrency</varname>. Setting these values for a particular tablespace will override the planner's usual estimate of the cost of reading pages from tables in - that tablespace, and the executor's prefetching behavior, as established + that tablespace, and how many concurrent I/Os are issued, as established by the configuration parameters of the same name (see <xref linkend="guc-seq-page-cost"/>, <xref linkend="guc-random-page-cost"/>, -- 2.48.1.76.g4e746b1a31.dirty --5i73spx2p4vwf7fe Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v2.12-0014-docs-Add-acronym-and-glossary-entries-for-I-O-.patch" ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick lz4 here. Users can still make the informed choice and switch to zstd if their workload works better there, but lz4 is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of lz4, zstd, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..39ec64a611a 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>lz4</literal>, + <literal>zstd</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..ff108e3d3a5 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, lz4, zstd, or pglz (on = lz4 if + # available, else zstd if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..8daf24d93cf 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer lz4 when compiled in; otherwise use zstd if available, falling back + * to pglz. + */ +#if defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#elif defined(USE_ZSTD) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --vDkUrtfZPOyy795V-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
* [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz @ 2026-07-31 12:24 Christoph Berg <myon@debian.org> 0 siblings, 0 replies; 333+ messages in thread From: Christoph Berg @ 2026-07-31 12:24 UTC (permalink / raw) Previously, wal_compression=on was an alias for pglz, with the idea that users could make an informed choice to pick a better option. But in practice, users either don't want to make that choice (they just want WAL compression), can't really pick the best option (they are setting the default in an environment where someone else is running the workload), or simply don't know that there are other options (previously, "on" was the only choice available). In all these cases, mapping "on" to something that isn't pglz is better. It is strictly slower and does not compress better. We pick zstd here. Users can still make the informed choice and switch to lz4 if their workload works better there, but zstd is still better than pglz in that case. Like for the default TOAST compression, the actual default "on" value depends on if PostgreSQL was compiled with the compression algorithms. The first of zstd, lz4, pglz is picked. (Only the latter is always available, but practically, builds will have at least one of the better algorithms.) --- doc/src/sgml/config.sgml | 12 ++++++------ src/backend/utils/misc/guc_tables.c | 8 ++++---- src/backend/utils/misc/postgresql.conf.sample | 3 ++- src/include/access/xlog.h | 13 +++++++++++++ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index aa7b1bd75d2..9bfe0443848 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3667,12 +3667,12 @@ include_dir 'conf.d' <xref linkend="guc-full-page-writes"/> is on, during a base backup, etc.). A compressed page image will be decompressed during WAL replay. - The supported methods are <literal>pglz</literal>, - <literal>lz4</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-lz4</option>) and - <literal>zstd</literal> (if <productname>PostgreSQL</productname> - was compiled with <option>--with-zstd</option>). - The value <literal>on</literal> is a historical spelling of <literal>pglz</literal>. + The supported methods are <literal>off</literal>, <literal>on</literal>, + <literal>zstd</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-zstd</option>) + <literal>lz4</literal> (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>), and + <literal>pglz</literal>. + The value <literal>on</literal> selects the first of <literal>zstd</literal>, + <literal>lz4</literal>, <literal>pglz</literal> that is available. The default value is <literal>off</literal>. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 1ec460b6a82..e0b21053287 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -484,13 +484,13 @@ static const struct config_enum_entry wal_compression_options[] = { #ifdef USE_ZSTD {"zstd", WAL_COMPRESSION_ZSTD, false}, #endif - {"on", WAL_COMPRESSION_PGLZ, false}, + {"on", DEFAULT_WAL_COMPRESSION, false}, {"off", WAL_COMPRESSION_NONE, false}, - {"true", WAL_COMPRESSION_PGLZ, true}, + {"true", DEFAULT_WAL_COMPRESSION, true}, {"false", WAL_COMPRESSION_NONE, true}, - {"yes", WAL_COMPRESSION_PGLZ, true}, + {"yes", DEFAULT_WAL_COMPRESSION, true}, {"no", WAL_COMPRESSION_NONE, true}, - {"1", WAL_COMPRESSION_PGLZ, true}, + {"1", DEFAULT_WAL_COMPRESSION, true}, {"0", WAL_COMPRESSION_NONE, true}, {NULL, 0, false} }; diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7958653077b..9d178fb09c1 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -262,7 +262,8 @@ #wal_log_hints = off # also do full page writes of non-critical updates # (change requires restart) #wal_compression = off # enables compression of full-page writes; - # off, pglz (or "on"), lz4, or zstd + # off, on, zstd, lz4, or pglz (on = zstd if + # available, else lz4 if available, else pglz) #wal_init_zero = on # zero-fill new WAL files #wal_recycle = on # recycle WAL files #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4dd98624204..9259b3461c7 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -87,6 +87,19 @@ typedef enum WalCompression WAL_COMPRESSION_ZSTD, } WalCompression; +/* + * Choose an appropriate default WAL compression method for wal_compression=on. + * Prefer zstd when compiled in; otherwise use lz4 if available, falling back + * to pglz. + */ +#ifdef USE_ZSTD +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_ZSTD +#elif defined(USE_LZ4) +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_LZ4 +#else +#define DEFAULT_WAL_COMPRESSION WAL_COMPRESSION_PGLZ +#endif + /* Recovery states */ typedef enum RecoveryState { -- 2.53.0 --CjtMoaqLlMP6LcXJ-- ^ permalink raw reply [nested|flat] 333+ messages in thread
end of thread, other threads:[~2026-07-31 12:24 UTC | newest] Thread overview: 333+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2025-03-19 14:15 [PATCH v2.12 13/28] Enable IO concurrency on all systems Andres Freund <andres@anarazel.de> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v4] Change wal_compression=on to the first of lz4, zstd, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org> 2026-07-31 12:24 [PATCH v3] Change wal_compression=on to the first of zstd, lz4, pglz Christoph Berg <myon@debian.org>
This inbox is served by agora; see mirroring instructions for how to clone and mirror all data and code used for this inbox