Re: WAL compression setting after PostgreSQL LZ4 default change

From: Tomas Vondra <tomas(at)vondra(dot)me>
To: Hannu Krosing <hannuk(at)google(dot)com>
Cc: Andreas Karlsson <andreas(at)proxel(dot)se>, Christoph Berg <myon(at)debian(dot)org>, Andrey Borodin <x4mmm(at)yandex-team(dot)ru>, wenhui qiu <qiuwenhuifx(at)gmail(dot)com>, Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>, Andres Freund <andres(at)anarazel(dot)de>, Jelte Fennema-Nio <postgres(at)jeltef(dot)nl>, Michael Paquier <michael(at)paquier(dot)xyz>, Japin Li <japinli(at)hotmail(dot)com>, Fujii Masao <masao(dot)fujii(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, John Naylor <johncnaylorls(at)gmail(dot)com>
Subject: Re: WAL compression setting after PostgreSQL LZ4 default change
Date: 2026-08-04 10:01:40
Message-ID: 97667b29-9b73-4418-93de-e1928c236b66@vondra.me
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 8/4/26 09:03, Hannu Krosing wrote:
> On Mon, Aug 3, 2026 at 10:36 PM Tomas Vondra <tomas(at)vondra(dot)me> wrote:
>>
>> On 8/3/26 15:36, Hannu Krosing wrote:
>>> For the CPU usage vs compression ratio discussion, please remember
>>> that for both lz4 and zstd this depends on certain "compression
>>> effort" flags, which we do not expose to customers (we claim we
>>> already choose the best ones for them :) )
>>>
>>
>> I'm not sure we really make such claims.
>
> Yeah, I re-checked and all the claims I remembered were from mailing
> list discussions, not official docs.
>
>> AFAIK we simply use the default
>> compression levels, specified by the lz4/zstd library, and assume the
>> authors picked the right trade offs. I think that's sensible.
>
> It's a bit more complicated than that - we use zstd level 1 while the
> default for the zstd command-line utility is level 3
>
> We should keep this in mind when running any manual compression tests.
>

Are you sure? Because I see xloginsert.c does this:

len = ZSTD_compress(dest, COMPRESS_BUFSIZE, source, orig_len,
ZSTD_CLEVEL_DEFAULT);

and ZSTD_CLEVEL_DEFAULT (=3) is the constant from zstd library. So at
least for WAL we should be using the "normal" compression level.

> My recollection from running some manual tests a year or two ago is
> that on compression side there was a fair bit of overlap in speed
> between lz4 and zstd when looking across many compression levels.
>
> However, lz4 was a clear winner in decompression speeds, being 2-3
> times faster than zstd.
>

Seems plausible.

I'm running some simple tests, to get a better idea how the algorithms
compare. I have no intention to tune the current compression levels.

regards

--
Tomas Vondra

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Daniel Gustafsson 2026-08-04 10:02:43 Re: data_checksums + debug_discard_caches = crash
Previous Message solai v 2026-08-04 09:43:11 Re: pg_xmin_horizon: a system view of everything pinning the xmin horizon