Re: Lowering the default wal_blocksize to 4K

From: Andrew Pogrebnoi <andrew(dot)pogrebnoi(at)percona(dot)com>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: pgsql-hackers(at)postgresql(dot)org, Heikki Linnakangas <hlinnaka(at)iki(dot)fi>, Robert Haas <robertmhaas(at)gmail(dot)com>, Thomas Munro <thomas(dot)munro(at)gmail(dot)com>, Matthias van de Meent <boekewurm+postgres(at)gmail(dot)com>
Subject: Re: Lowering the default wal_blocksize to 4K
Date: 2026-02-17 20:06:14
Message-ID: CA+aWR11Gvz4RvPaBx1kfpTx2QxpNW46Yv120dDcUA93UbYcxrg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On Mon, Feb 16, 2026 at 11:13 PM Andres Freund <andres(at)anarazel(dot)de> wrote:
> Hi,
>
> On 2026-02-16 10:04:37 +0200, Andy Pogrebnoi wrote:
> > Since we recycle WAL segments, the added size won't go to the disk
usage but
> > rather cause a bit more freqent segment.
>
> I don't think that's a valid argument though, how much WAL needs to be
> archived is a relevant factor.

Yes, indeed.

> If NBuffers / 32 < wal_segment_size / XLOG_BLCKSZ, the chosen xbuffers
value
> does not depend on XLOG_BLCKSZ.
>
> To me the code only makes sense if you assume that NBuffers / 32 gives
you a
> value in the same domain as data blocks, otherwise NBuffers / 32 is not
the
> approximation of %3 that the comment talks about.
>
>
> I think the code just needs to be fixed to multiply NBuffers * BLCKSZ and
then
> divide that by XLOG_BLCKSZ.

You are right, my bad, fixed (v2-0002).

> I think the auto-tuning bit above needs to be fixed, and it's probably
worth
> manually testing a pg_upgrade from 8kB XLOG_BLCKSZ to 4kB. It should
work, but

pg_upgrade ran with no issues, and the database started with the new (4kB)
XLOG_BLCKSZ

I also found and fixed some more mentions of 8kB as the default for
XLOG_BLCKSZ in the
documentation (v2-0001).

---
Cheers,
Andy

Attachment Content-Type Size
v2-0001-Change-default-wal_blocksize-to-4KB.patch application/octet-stream 6.1 KB
v2-0002-Fix-XLOG-buffers-auto-tune-for-different-XLOG_BLC.patch application/octet-stream 942 bytes

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Geoghegan 2026-02-17 20:16:06 Re: index prefetching
Previous Message Andres Freund 2026-02-17 19:58:22 Re: POC: Carefully exposing information without authentication