Re: Add a pg_wal_preallocate() SQL function to eagerly create future WAL segments

From: Ayush Tiwari <ayushtiwari(dot)slg01(at)gmail(dot)com>
To: solai v <solai(dot)cdac(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Ian Lawrence Barwick <barwick(at)gmail(dot)com>
Subject: Re: Add a pg_wal_preallocate() SQL function to eagerly create future WAL segments
Date: 2026-08-03 05:13:28
Message-ID: CAJTYsWXG_KB2wxWwnKkwNrXQuqms08JCpRV9S6Snogvj-L+9gQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On Fri, 31 Jul 2026 at 15:31, solai v <solai(dot)cdac(at)gmail(dot)com> wrote:

> Hi all,
>
> Thanks for the updated patch. I tested this patch and was able to
> verify the new pg_wal_preallocate() functionality on a freshly
> initialized cluster. Before invoking the function, the pg_wal
> directory contained a single WAL segment. Executing: SELECT
> pg_wal_preallocate(), returned 5, and I confirmed that 5 additional
> WAL segment files were created in the pg_wal directory, matching the
> configured min_wal_size target. I also verified the updated default
> behavior discussed in the thread. The default invocation only created
> the missing segments needed to satisfy the min_wal_size window ahead
> of the current insertion point, rather than creating an arbitrary
> number of WAL segments. I then reset the WAL and I/O statistics and
> executed a workload generating approximately 3.3 GB of WAL using a
> 5-million-row INSERT. Since the default invocation only preallocated
> enough segments to satisfy min_wal_size (80 MB in my setup), the
> workload still required additional WAL segment creation during
> execution. This behavior seems consistent with the intended design and
> the discussion in the thread. I did not encounter any functional
> issues during testing.
>

Thanks for testing!

Rebased patch attached.

Regards,
Ayush

Attachment Content-Type Size
v3-0001-pg_wal_preallocate.patch application/octet-stream 17.2 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Chao Li 2026-08-03 05:16:58 Re: tablecmds: fix bug where index rebuild loses replica identity on partitions
Previous Message Ayush Tiwari 2026-08-03 05:10:49 Re: Avoid unnecessary server restarts in the Kerberos TAP test