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-03-23 01:14:23
Message-ID: CAH2-Wz=Vxsgas35ZzOJJW1ceqp9TJ2DFhKmXULwUAcVpfD73xA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, Mar 21, 2026 at 7:01 PM Peter Geoghegan <pg(at)bowt(dot)ie> wrote:
> I can immediately act on most of what you've said here. I'm planning
> to commit the first patch (and maybe the hash index fake LSN patch) in
> the next couple of days, ahead of posting a new v17 of the patch set.
> You can expect any item I reply to with "fixed" or similar to be in
> that version. Other items might not be addressed in v17 -- generally
> because I require more context or feedback to act.
>
> I'm going to work through both this email and the later one from today
> before posting this v17. What I've said applies equally to both
> reviews/emails.

I committed the fake LSN hash index patch (as commit e5836f7b), as
well as the "Make IndexScanInstrumentation a pointer in executor scan
nodes" patch (as commit f026fbf0).

V17 is attached. This addresses most of your feedback, but defers
dealing with the trickier parts for now. I didn't want to delay
producing a new version that cleanly applies on top of master.
Performance validation takes at least as long as writing the code,
with these sorts of changes.

Notable things that I have *not* done just yet:

* No new heapam_index.c file in this version (though there is an indexbatch.h).

* No split of table AM revisions that pushes down VM accesses for
index-only scans into its own commit (though there are a couple of new
patches that were split from the big one to keep the size of the
commits slightly more manageable, as promised).

* No progress on splitting the batch management code currently in
heapam_handler.c into smaller, reusable/modular pieces. Pieces that
other table AMs can reuse.

* Recently, Andres asked, "Does it really make sense to not just have
2 separate loops from within heapam_batch_resolve_visibility?". That
is a question that remains unanswered, for now.

Notable changes (things that I *have* done) include:

* Cleaned up the mess of carrying around four full-length, specialized
versions of the table AM index scan slot callback. We still
specialize, but now there's only one generic
pg_attribute_always_inline function definition, which is called by all
four specializations. The compiler can create specialized versions
because the amgetbatch + index_only_scan parameters are constants
(four specializations for all four combinations of amgetbatch +
index_only_scan boolean parameters).

* Lots of renaming and polishing, along the lines requested in your
review. Basically, everything I specifically told you I would do soon
in my initial responses over the past couple of days has been
completed. A large number of small things, that aren't worth noting
individually.

--
Peter Geoghegan

Attachment Content-Type Size
v17-0001-Track-index-only-scan-heap-fetches-using-IndexSc.patch application/octet-stream 5.4 KB
v17-0017-WIP-instrumentation-Account-for-resource-usage-u.patch application/octet-stream 1.4 KB
v17-0018-Dirty-hack-to-make-read_stream_reset-end-not-wai.patch application/octet-stream 4.4 KB
v17-0016-WIP-aio-io_uring-Use-IO-size-not-IO-queue-to-tri.patch application/octet-stream 4.1 KB
v17-0015-WIP-read_stream-Prevent-distance-from-decaying-t.patch application/octet-stream 2.9 KB
v17-0014-WIP-read_stream-Only-increase-distance-when-wait.patch application/octet-stream 2.3 KB
v17-0013-bufmgr-Return-whether-WaitReadBuffers-needed-to-.patch application/octet-stream 2.8 KB
v17-0011-WIP-read_stream-Issue-IO-synchronously-while-in-.patch application/octet-stream 2.0 KB
v17-0012-WIP-aio-io_uring-Allow-IO-methods-to-check-if-IO.patch application/octet-stream 4.6 KB
v17-0010-Don-t-wait-for-already-in-progress-IO.patch application/octet-stream 20.6 KB
v17-0008-Make-hash-index-AM-use-amgetbatch-interface.patch application/octet-stream 46.0 KB
v17-0009-Make-buffer-hit-helper.patch application/octet-stream 6.0 KB
v17-0006-Add-UnlockBufferGetLSN-utility-function.patch application/octet-stream 3.5 KB
v17-0005-Optimize-heap-buffer-pin-transfer-for-last-in-bl.patch application/octet-stream 5.3 KB
v17-0007-Add-heapam-index-scan-I-O-prefetching.patch application/octet-stream 42.9 KB
v17-0004-Implement-VISITED_PAGES_LIMIT-within-heapam.patch application/octet-stream 4.6 KB
v17-0003-Add-interfaces-that-enable-index-prefetching.patch application/octet-stream 266.0 KB
v17-0002-heapam-Track-heap-block-in-IndexFetchHeapData-us.patch application/octet-stream 4.1 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jianghua Yang 2026-03-23 01:36:22 Re: basebackup: add missing deflateEnd() in gzip compression sink
Previous Message Michael Paquier 2026-03-23 00:55:24 Re: Change checkpoint‑record‑missing PANIC to FATAL