Re: WAL compression setting after PostgreSQL LZ4 default change
Japin Li <japinli@hotmail.com>
From: Japin Li <japinli@hotmail.com>
To: wenhui qiu <qiuwenhuifx@gmail.com>
Cc: Michael Paquier <michael@paquier.xyz>, pgsql-hackers
<pgsql-hackers@postgresql.org>, John Naylor <johncnaylorls@gmail.com>,
Christoph Berg <myon@debian.org>
Date: 2026-07-03T02:18:08Z
Lists: pgsql-hackers
On Wed, 01 Jul 2026 at 09:53, wenhui qiu <qiuwenhuifx@gmail.com> wrote: > Hi Michael > > > If I were switch the default, for me zstd goes first, lz4 is a close > > second, and pglz is the last of its class. The only reason why we > > have not chosen zstd for TOAST is the fact that we don't support it > > (trickier to add support for it as we have to preserve on-disk > > compatibility for inline compressed TOAST entries). > > > In short, lz4 is available in many environments, but I'm also ready to > > bet that zstd is equally available in these environments. > Thanks for the feedback. > > Yes, I did consider zstd as well. I agree that zstd can provide a better > compression ratio than lz4, and if we only look at compression ratio, zstd is > a very attractive choice. > > The reason I started with lz4 was mainly to keep this change aligned with the > recent TOAST compression change. Since lz4 has already been accepted there as > the preferred default when available, I thought using the same choice for > wal_compression=on would make the proposal smaller, more consistent, and easier > to evaluate. so > > Second, WAL compression happens on the WAL insertion path for full-page images, > so compression speed and CPU overhead matter a lot. lz4 is generally a good fit > for that trade-off: it still reduces WAL volume, while keeping compression > latency and CPU cost lower than zstd in many workloads. > > That said, I understand the argument for preferring zstd when it is available. > I have prepared an alternative version where wal_compression=on selects zstd > first, then lz4 if zstd is not available, and finally pglz as the fallback > > Thanks Thanks for updating the patch. I've registered it in the CommitFest [1]. [1] https://commitfest.postgresql.org/patch/6979/ -- Regards, Japin Li ChengDu WenWu Information Technology Co., Ltd.