Re: index prefetching

From: Peter Geoghegan <pg(at)bowt(dot)ie>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: Tomas Vondra <tomas(at)vondra(dot)me>, Alexandre Felipe <o(dot)alexandre(dot)felipe(at)gmail(dot)com>, Thomas Munro <thomas(dot)munro(at)gmail(dot)com>, Nazir Bilal Yavuz <byavuz81(at)gmail(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Melanie Plageman <melanieplageman(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Georgios <gkokolatos(at)protonmail(dot)com>, Konstantin Knizhnik <knizhnik(at)garret(dot)ru>, Dilip Kumar <dilipbalaut(at)gmail(dot)com>
Subject: Re: index prefetching
Date: 2026-04-06 15:39:39
Message-ID: CAH2-Wz=DE8bjKKNuM-AiH=QUebvjcpqVa6eGzraZ2NOoTECoHg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Apr 6, 2026 at 9:09 AM Andres Freund <andres(at)anarazel(dot)de> wrote:
> Quite a few people have tried very hard over the last months to get this, and
> its dependencies, into a committable shape. The patchset is much better than
> it was. The performance is better. Regressions are drastically reduced. The
> performance gains are often unbelievably large.
>
> I'd be happy to merge the patchset from the performance POV. I'd be happy to
> merge it from a high-level architectural perspective. It's just the pesky
> details that need more buffing out than our tired arms can do in the remaining
> time. I think Peter feels similar.

That's a good summary.

At a high level, the patch has no significant problems. It introduces
virtually no regressions, which required a great deal of effort from
all of us -- that exceeds what I once thought possible. There's a
general sense that the high level architecture is a big improvement,
without any notable flaws.

As you said, it came down to lots of small things. And timing. Many
last minute non-trivial changes to specific aspects of the patch
design seemed necessary. This all happened under enormous time
pressure. And I'm honestly just exhausted right now (I'm likely not
the only one). I just couldn't justify committing such an invasive
patch set under those circumstances.

Attached is v24 -- one last revision ahead of feature freeze, just to
post what I have, before taking some time away from this.

Summary of changes from v23:

* index_getnext_tid is renamed and moved into indexbatch.h, where it
becomes a utility function that has a similar contract to the one that
is used to call amgetbatch (and manage changes in the batch
direction). Now there's only one canonical call to
pgstat_count_index_tuples in heapam, and no accidental table index
fetch state resets when a scan that happens to be using amgettuple
ends.

* Miscellaneous small cleanups, including renaming some of the
functions in indexbatch.c.

* Slightly simplified tableam_util_batchscan_mark_pos logic.

Obviously this isn't everything that I'd hoped would appear in the
next revision. It's just what got done in the past 24 hours.

--
Peter Geoghegan

Attachment Content-Type Size
v24-0007-aio-Fix-pgaio_io_wait-for-staged-IOs-B.patch application/octet-stream 6.3 KB
v24-0006-Allow-read_stream_reset-to-not-wait-for-IO-compl.patch application/octet-stream 20.5 KB
v24-0001-Add-slot-based-table-AM-index-scan-interface.patch application/octet-stream 79.6 KB
v24-0008-WIP-aio-bufmgr-Fix-race-condition-leading-to-dea.patch application/octet-stream 3.1 KB
v24-0003-Adopt-amgetbatch-interface-in-hash-index-AM.patch application/octet-stream 48.0 KB
v24-0004-heapam-Optimize-pin-transfers-during-index-scans.patch application/octet-stream 6.8 KB
v24-0002-Add-amgetbatch-interface-and-adopt-it-in-nbtree.patch application/octet-stream 245.4 KB
v24-0005-heapam-Add-index-scan-I-O-prefetching.patch application/octet-stream 48.9 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Jacob Champion 2026-04-06 15:43:00 Re: PG 19 release notes and authors
Previous Message Robert Haas 2026-04-06 15:38:41 Re: PG 19 release notes and authors