Re: Compression of bigger WAL records

From: Tomas Vondra <tomas(at)vondra(dot)me>
To: Andrey Borodin <x4mmm(at)yandex-team(dot)ru>, Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>
Cc: pgsql-hackers mailing list <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Michael Paquier <michael(at)paquier(dot)xyz>, Japin Li <japinli(at)hotmail(dot)com>
Subject: Re: Compression of bigger WAL records
Date: 2026-11-23 20:46:14
Message-ID: d7b4b31b-8f32-456d-a832-d9b3e2cfe44a@vondra.me
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 11/8/26 08:49, Andrey Borodin wrote:
> Hi Zsolt!
>
> On 26 Oct 2026, Zsolt Parragi wrote:
>> Won't this result in a performance regression with the additional
>> blocks when the header crosses multiple pages?
>
> v12 stops nonblocking read-ahead at a split header even with free decode
> space. In v13 it assembles the record and retries allocation from the
> decode ring. If the ring is full, it yields without advancing
> NextRecPtr.
>
>> Shouldn't this flag be unset after decompression?
>
> Agreed. With streams enabled, replication origin SET and DROP records
> are reported as UNKNOWN. v13 clears XLR_COMPRESSED after decompression.
> The new test checks both record names and that compression was used.
> pg_waldump still displays physical lengths when they differ from decoded
> lengths.
>
>
>> And: it seems like that the patchset tries to compress incompressible
>> FPI records twice (first record, then whole page, failing both times)?
>
> I removed the second codec pass in 0001.
>
> Thank you!
>
>
> Best regards, Andrey Borodin.

Hi,

The patches need a rebase (just minor bitrot). I've only quickly skimmed
the patches, but I do have a couple questions:

1) Are there any motivating benchmarks, quantifying the benefits on
"average" and "best-case" workloads / datasets. Is the point a better
compression ratio, lower CPU usage, or something else? What benefits
should we expect for cases plausible in real world?

2) wal_compression_threshold - I kinda dislike this GUC name, because it
implies it's about "wal compression" in general, and completely hides
that it's about whole-record compression.

3) The docs say this in a couple places:

Total amount of WAL full page images in bytes, after per-image
compression but before whole-record compression. This can exceed
<structfield>wal_bytes</structfield> when whole records are
compressed: their compressed payload cannot be split into image
and non-image portions.

I really don't understand the point of this. I mean, what does that tell
me? It's not the "raw" size of WAL, because it's already compressed, but
it's also not really the "compressed" size, because we're going to try
the whole-record compression. How is this useful? I'm puzzled.

4) In another place, the docs say this:

Lowering this value does not simply compress more. A record taken by
whole-record compression no longer has its page images compressed
individually. The compressed record, including its header, is used
only if smaller than the uncompressed record. Otherwise the record
is written uncompressed, without retrying per-image compression.
The result is not compared with per-image compression.
A lower threshold can therefore produce
<emphasis>more</emphasis> WAL than per-image compression.
Setting it above the size of the largest possible WAL
record disables whole-record compression entirely, leaving the
page-image compression that <xref linkend="guc-wal-compression"/>
performed before this setting existed.

That seems rather vague. Like, how would I know how to pick a good
value? What are good values? What are the min/max values?

FWIW I don't think we should be adding infinite number of knobs - if the
512B default is good, then lets use that, and maybe have a #define to
override that, same as we have TOAST_TUPLE_THRESHOLD.

regards

--
Tomas Vondra

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message surya poondla 2026-11-23 21:31:53 Re: Fix FATAL error when using recovery_target = 'immediate' on cleanly shut down clusters
Previous Message Alexandre Felipe 2026-11-23 20:33:24 Re: pg_regress: schedule multi-line test groups