Re: index prefetching
Tomas Vondra <tomas@vondra.me>
Commits
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
aio: io_uring: Trigger async processing for large IOs
- a9ee66881744 19 (unreleased) landed
-
read stream: Split decision about look ahead for AIO and combining
- 8ca147d582a5 19 (unreleased) landed
-
read_stream: Only increase read-ahead distance when waiting for IO
- f63ca3379025 19 (unreleased) landed
-
read_stream: Prevent distance from decaying too quickly
- 6e36930f9aaf 19 (unreleased) landed
-
Reduce ExecSeqScan* code size using pg_assume()
- b227b0bb4e03 19 (unreleased) cited
-
Fix rare bug in read_stream.c's split IO handling.
- b421223172a2 19 (unreleased) cited
-
Fix multiranges to behave more like dependent types.
- 3e8235ba4f9c 17.0 cited
-
Add EXPLAIN (MEMORY) to report planner memory consumption
- 5de890e3610d 17.0 cited
-
Optimize nbtree backward scan boundary cases.
- c9c0589fda0e 17.0 cited
-
Increment xactCompletionCount during subtransaction abort.
- 90c885cdab8b 14.0 cited
-
Add nbtree Valgrind buffer lock checks.
- 4a70f829d86c 14.0 cited
-
Add nbtree high key "continuescan" optimization.
- 29b64d1de7c7 12.0 cited
-
Reduce pinning and buffer content locking for btree scans.
- 2ed5b87f96d4 9.5.0 cited
-
Teach btree to handle ScalarArrayOpExpr quals natively.
- 9e8da0f75731 9.2.0 cited
Attachments
- v20240930-0001-WIP-index-batching-prefetching.patch (text/x-patch) patch v20240930-0001
- v20240930-0002-WIP-batching-for-nbtree-indexes.patch (text/x-patch) patch v20240930-0002
- v20240930-0003-PoC-support-for-mark-restore-for-nbtree.patch (text/x-patch) patch v20240930-0003
- v20240930-0004-WIP-batching-for-hash-indexes.patch (text/x-patch) patch v20240930-0004
- v20240930-0005-WIP-batching-for-gist-indexes.patch (text/x-patch) patch v20240930-0005
- v20240930-0006-WIP-batching-for-sp-gist-indexes.patch (text/x-patch) patch v20240930-0006
Hi, Here's another version of this patch series, with a couple significant improvements, mostly in the indexam.c and executor layers. The AM code remains almost untouched. I have focused on the simplification / cleanup of the executor code (nodeIndexscan and nodeIndexonlyscan). In the previous version there was quite a bit of duplicated code - both for the "regular" index scans and index-only scans, the "while getnext" block was copied, calling either the non-batched or batched functions. That is now mostly gone. I managed to move 99% of the differences to the indexam.c layer, so that the executor simply calls index_getnext_tid() or index_getnext_slot(), and that decides *internally* whether to use the batched version, or not. This means the only new function added to the indexam API is index_batch_add(), which the index AMs use to add items into the batch. For the executor the code remains the same. The only exception is that index-only scans need a way to guide the prefetching based on the visibility map (we don't want to prefetch all-visible pages, because skipping those is the whole point of IOS). And we also want a way to share the VM check, so that it doesn't need to happen twice. Because for fully-cached workloads this is too expensive. Doing the first part is trivial - we simply define a callback for the batching, responsible for inspecting the VM and making a decision. That's easy, and fairly clean. Passing the VM check result back is a bit awkward, though. The current patch deals with it by just executing the callback again (which just returns the cached result), or doing the VM check locally (for non-batched version). It's not pretty, because it leaks knowledge of the batching into the executor. I'd appreciate ideas how to solve this in a nicer way. I've also split the nbtree changes into a separate patch. It used to be included in the first patch, but I've decided to keep it separate, just like for the other AMs. I'm now fairly happy with both the executor layer and the (much smaller) indexam.c code, and I think it's in a good enough shape for a review. The next item on my TODO is cleanup of the nbtree code, particularly the mark/restore part in patch 0003. So I'll work on that next. I also plan to get back to the index_batch_prefetch() code, which is not wrong but would benefit from a bit of cleanup / clarification etc. regards -- Tomas Vondra