| From: | Tomás Senart <ts(at)perfloop(dot)ai> |
|---|---|
| To: | pgsql-hackers(at)lists(dot)postgresql(dot)org |
| Subject: | [PATCH v1] Batch B-tree TIDs when building a bitmap |
| Date: | 2026-09-19 00:13:05 |
| Message-ID: | CAEEBa3U7QDChb=PjzQGHoie-tOnfr7dumhO12Tp=5o2iT4t_ug@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi,
I would like review of this B-tree bitmap-scan patch. Perfloop's agent
found and implemented it; the patch and submission packet used AI
assistance. I am the contact.
btgetbitmap calls tbm_add_tuples once per matching TID. The patch batches
saved leaf-page spans to reuse that API's within-call heap-block cache [1].
The first TID keeps the scalar path. Remaining spans use a buffer with
less than 8 KiB of payload for 8 KiB pages, allocated once per primitive
scan and reused. All-singleton scans avoid allocation. No API, disk format,
planner rule, or TID order changes.
One-, two-, and eight-span tests found no clear target benefit from larger
batches. Eight helped the largest scattered control by 0.97%; one uses
less memory.
On one Linux/x86-64 GCP VM, ten paired runs per query showed:
10M rows, 3M matches: 29.937 ms paired saving (14.2%).
2M rows, 200K matches: 1.766 ms paired saving (13.6%).
These are whole-run mean transaction times from single-client pgbench,
with forced bitmap plans. Copy and allocation costs are included.
Nine controls, including scattered and single-row queries, passed a
predeclared 5% practical-loss ceiling. This does not prove zero regression.
All 240 core regression tests passed. Full test counts, skips, build
limits, paired intervals, and reproduction instructions are attached.
The scripts do not require Perfloop.
Base: master 0c5d6269614e107d1d2d669f82f63f7e232b30c9 (20devel).
The v34 Index Prefetching patch [2] changes the same loop but still passes
one TID per bitmap call. We have not tested the changes together.
I would welcome review of the batching boundary, small-scan path, and
other workload cases.
Thanks,
Tomás
[1] https://github.com/postgres/postgres/commit/f5ae3ba4828ece02bae2d16b4cbce847fbcea850
[2] https://www.postgresql.org/message-id/attachment/203026/v34-0003-Add-amgetbatch-interface-and-adopt-it-in-nbtree.patch
| Attachment | Content-Type | Size |
|---|---|---|
| v1-0001-Batch-B-tree-TIDs-when-building-a-bitmap.patch | text/x-patch | 6.2 KB |
| results.md | text/markdown | 9.4 KB |
| reproduce.tar.gz | application/gzip | 23.5 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Bharath Rupireddy | 2026-09-19 00:26:45 | Re: Support for 8-byte TOAST values, round two |
| Previous Message | Michael Paquier | 2026-09-19 00:03:31 | Re: Support for 8-byte TOAST values, round two |