Re: Pre-allocating WAL files - Mailing list pgsql-hackers

From Nathan Bossart
Subject Re: Pre-allocating WAL files
Date
Msg-id Z4_Hmj2R8NXnAI-K@nathan
Whole thread Raw
In response to Re: Pre-allocating WAL files  (Nathan Bossart <nathandbossart@gmail.com>)
Responses Re: Pre-allocating WAL files
List pgsql-hackers
On Tue, Jan 21, 2025 at 09:52:51AM -0600, Nathan Bossart wrote:
> On Tue, Jan 21, 2025 at 03:31:27AM +0000, Andy Fan wrote:
>> 3. Why is the purpose of preallocated_segments directory? what in my
>> mind is we just prellocate the normal filename so that XLogWrite could
>> open it directly. This is same as what wal_recycle does and we can reuse
>> the same strategy to clean up them if they are not needed anymore.
> 
> The purpose is to limit the use of pre-allocated segments to only
> situations where WAL recycling is not sufficient.  Basically, if writing a
> record would require a new segment to be created, we can quickly pull a
> pre-allocated one instead of creating it ourselves.  Besides simplifying
> matters, this prevents a lot of unnecessary pre-allocation, since many
> workloads will almost never need anything beyond the recycled segments.

That being said, it would be nice to avoid the fsync() overhead to move a
pre-allocated WAL into place.  My first instinct is that would be
substantially more complicated and may not actually improve matters all
that much, but I agree that it's worth exploring.

-- 
nathan



pgsql-hackers by date:

Previous
From: Benoit Lobréau
Date:
Subject: doc: explain pgstatindex fragmentation
Next
From: Corey Huinker
Date:
Subject: Re: Statistics Import and Export