On Tue, Feb 15, 2022 at 11:54:10AM -0800, Andres Freund wrote: > > Isn't it an incontrovertible fact that LZ4 is superior to pglz in > > every way? LZ4 is pretty much its successor. And so it seems totally > > fine to assume that users will always want to use the clearly better > > option, and that that option will be generally available going > > forward. TOAST compression is applied selectively already, based on > > various obscure implementation details, some of which are quite > > arbitrary. > > Yea, we should really default to lz4 in initdb when available.
This patch intends to implement that. I have no particular interest in this, but if anyone wants, I will add it to the next CF (or the one after that). commit 2a3c5950e625ccfaebc49bbf71b8db16dc143cd2 Author: Justin Pryzby <pryz...@telsasoft.com> Date: Tue Feb 15 19:14:33 2022 -0600 initdb: default_toast_compression=lz4 if available TODO: consider same for wal_compression diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index fc63172efde..f9cd2ef7229 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -8537,7 +8537,9 @@ COPY postgres_log FROM '/full/path/to/logfile.csv' WITH csv; The supported compression methods are <literal>pglz</literal> and (if <productname>PostgreSQL</productname> was compiled with <option>--with-lz4</option>) <literal>lz4</literal>. - The default is <literal>pglz</literal>. + The default is <literal>lz4</literal> if available at the time + <productname>PostgreSQL</productname> was compiled, otherwise + <literal>pglz</literal>. </para> </listitem> </varlistentry> diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index f505413a7f9..6b6f6efaba1 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -4726,7 +4726,11 @@ static struct config_enum ConfigureNamesEnum[] = NULL }, &default_toast_compression, +#ifdef USE_LZ4 + TOAST_LZ4_COMPRESSION, +#else TOAST_PGLZ_COMPRESSION, +#endif default_toast_compression_options, NULL, NULL, NULL }, diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c index d78e8e67b8d..bb7c57e00fa 100644 --- a/src/bin/initdb/initdb.c +++ b/src/bin/initdb/initdb.c @@ -1185,6 +1185,12 @@ setup_config(void) "#update_process_title = off"); #endif +#ifdef USE_LZ4 + conflines = replace_token(conflines, + "#default_toast_compression = 'pglz'", + "#default_toast_compression = 'lz4'"); +#endif + /* * Change password_encryption setting to md5 if md5 was chosen as an * authentication method, unless scram-sha-256 was also chosen.