Re: Avoiding smgrimmedsync() during nbtree index builds - Mailing list pgsql-hackers

From Robert Haas
Subject Re: Avoiding smgrimmedsync() during nbtree index builds
Date
Msg-id CA+Tgmoa+QFFhkHgPxyxv6t8aVU0r7GZmu7z8io4vGG7RHPpGzA@mail.gmail.com
Whole thread Raw
In response to Re: Avoiding smgrimmedsync() during nbtree index builds  (Melanie Plageman <melanieplageman@gmail.com>)
List pgsql-hackers
On Wed, Sep 29, 2021 at 2:36 PM Melanie Plageman
<melanieplageman@gmail.com> wrote:
> unbuffered_write() and unbuffered_extend() might be able to be used even
> if unbuffered_prep() and unbuffered_finish() are not used -- for example
> hash indexes do something I don't entirely understand in which they call
> smgrextend() directly when allocating buckets but then initialize the
> new bucket pages using the bufmgr machinery.

My first thought was that someone might do this to make sure that we
don't run out of disk space after initializing some but not all of the
buckets. Someone might have some reason for wanting to avoid that
corner case. However, in _hash_init() that explanation doesn't make
any sense, because an abort would destroy the entire relation. And in
_hash_alloc_buckets() the variable "zerobuf" points to a buffer that
is not, in fact, all zeroes. So my guess is this is just old, crufty
code - either whatever reasons somebody had for doing it that way are
no longer valid, or there wasn't any good reason even at the time.

-- 
Robert Haas
EDB: http://www.enterprisedb.com



pgsql-hackers by date:

Previous
From: "Joel Jacobson"
Date:
Subject: Re: Schema variables - new implementation for Postgres 15
Next
From: "Efrain J. Berdecia"
Date:
Subject: Re: Custom Operator for citext LIKE predicates question