Why do spgbuildempty(), btbuildempty(), and blbuildempty() use smgrwrite()?

From: Melanie Plageman <melanieplageman(at)gmail(dot)com>
To: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Why do spgbuildempty(), btbuildempty(), and blbuildempty() use smgrwrite()?
Date: 2022-03-03 01:07:14
Message-ID: CAAKRu_b6-NX8OKs02_WRcyuDwf0qBsRa7-Ecp3dGMxKHokzTMQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

If you enable the CHECK_WRITE_VS_EXTEND-protected assert in mdwrite(),
you'll trip it anytime you exercise btbuildempty(), blbuildempty(), or
spgbuildempty().

In this case, it may not make any meaningful difference if smgrwrite()
or smgrextend() is called (_mdfd_getseg() behavior won't differ even
with the different flags, so really only the FileWrite() wait event will
be different).
However, it seems like it should still be changed to call smgrextend().
Or, since they only write a few pages, why not use shared buffers like
gistbuildempty() and brinbuildempty() do?

I've attached a patch to move these three into shared buffers.

And, speaking of spgbuildempty(), there is no test exercising it in
check-world, so I've attached a patch to do so. I wasn't sure if it
belonged in spgist.sql or create_index_spgist.sql (on name alone, seems
like the latter but based on content, seems like the former).

- Melanie

Attachment Content-Type Size
v1-0001-Build-unlogged-index-init-fork-in-shared-buffers.patch text/x-patch 7.2 KB
v1-0002-Add-test-for-unlogged-SP-GiST-index.patch text/x-patch 1.9 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Justin Pryzby 2022-03-03 01:09:49 Re: Avoiding smgrimmedsync() during nbtree index builds
Previous Message Tatsuo Ishii 2022-03-03 01:01:36 Re: Proposal: Support custom authentication methods using hooks,Re: Proposal: Support custom authentication methods using hooks