Re: Revisiting {CREATE INDEX, REINDEX} CONCURRENTLY improvements

From: Michail Nikolaev <michail(dot)nikolaev(at)gmail(dot)com>
To: Matthias van de Meent <boekewurm+postgres(at)gmail(dot)com>
Cc: Michael Paquier <michael(at)paquier(dot)xyz>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Andrey Borodin <amborodin86(at)gmail(dot)com>, Melanie Plageman <melanieplageman(at)gmail(dot)com>
Subject: Re: Revisiting {CREATE INDEX, REINDEX} CONCURRENTLY improvements
Date: 2025-01-18 14:18:00
Message-ID: CANtu0ogtWQvWry72crtt7ZHq22ZLRprFYC_FW3VZ7qtQc1MwpQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello, everyone!

This is an updated version, contains some optimization into STIR index
access method, related to the fact it is never used with WAL.

> The locking in stirinsert can probably be improved significantly if
> we use things like atomic operations on STIR pages. We'd need an
> exclusive lock only for page initialization, while share locks are
> enough if the page's data is modified without WAL. That should improve
> concurrent insert performance significantly, as it would further
> reduce the length of the exclusively locked hot path.

Mathias, you were proposed to use just shared locking to writes, but how is
it possible if it is required to mark page as dirty, and it requires
exclusive lock?

> It occurs because the first phase is slow, and many tuples need to be
inserted during the validation phase.
> For each tuple, heapam_index_fetch_tuple is called, even for those on the
same page.
> It might be possible to implement a batched version of
heapam_index_fetch_tuple to handle multiple tuples on the same page and
mitigate this issue.

It was a wrong assumption. It looks like it is happening because of
prefetching. I'll try to add it in the validation phase.

Best regards,
Mikhail.

Attachment Content-Type Size
v12-0005-Allow-snapshot-resets-during-parallel-concurrent.patch application/octet-stream 34.1 KB
v12-0004-Allow-advancing-xmin-during-non-unique-non-paral.patch application/octet-stream 43.2 KB
v12-0003-Add-stress-tests-for-concurrent-index-operations.patch application/octet-stream 8.0 KB
v12-0002-This-is-https-commitfest.postgresql.org-50-5160-.patch application/octet-stream 17.5 KB
v12-0001-ExecInitAgg-update-aggstate-numaggs-and-numtrans.patch application/octet-stream 1.7 KB
v12-0007-Add-STIR-Short-Term-Index-Replacement-access-met.patch application/octet-stream 37.0 KB
v12-0006-Allow-snapshot-resets-in-concurrent-unique-index.patch application/octet-stream 39.0 KB
v12-0008-Improve-CREATE-REINDEX-INDEX-CONCURRENTLY-using-.patch application/octet-stream 102.0 KB
v12-0009-Concurrently-built-index-validation-uses-fresh-s.patch application/octet-stream 15.9 KB
v12-0010-Remove-PROC_IN_SAFE_IC-optimization.patch application/octet-stream 20.6 KB
v12-0012-Updates-index-insert-and-value-computation-logic.patch application/octet-stream 2.2 KB
v12-0011-Add-proper-handling-of-auxiliary-indexes-during-.patch application/octet-stream 28.7 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrey M. Borodin 2025-01-18 16:31:12 Re: Timeline issue if StartupXLOG() is interrupted right before end-of-recovery record is done
Previous Message Michail Nikolaev 2025-01-18 13:03:33 Re: Issue with markers in isolation tester? Or not?