Re: Adding skip scan (including MDAM style range skip scan) to nbtree

From: Peter Geoghegan <pg(at)bowt(dot)ie>
To: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
Cc: Masahiro Ikeda <ikedamsh(at)oss(dot)nttdata(dot)com>, Tomas Vondra <tomas(at)vondra(dot)me>, Masahiro(dot)Ikeda(at)nttdata(dot)com, pgsql-hackers(at)lists(dot)postgresql(dot)org, Masao(dot)Fujii(at)nttdata(dot)com
Subject: Re: Adding skip scan (including MDAM style range skip scan) to nbtree
Date: 2025-02-23 17:19:17
Message-ID: CAH2-Wzmxzs1-SvgoT+y84FzSpz8K1g33Cyby4hpn_GNiOw+CJA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Feb 14, 2025 at 6:06 PM Peter Geoghegan <pg(at)bowt(dot)ie> wrote:
> Attached is v24, which breaks out these recent changes to primscan
> scheduling into their own commit/patch (namely
> v24-0002-Improve-nbtree-SAOP-primitive-scan-scheduling.patch). The
> primscan scheduling improvement stuff hasn't really changed since
> v23, though (though I did polish it some more). I hope to be able to
> commit this new primscan scheduling patch sooner rather than later
> (though I don't think that it's quite committable yet).

The patch series recently bitrot due to conflicting changes on HEAD,
so I decided to post a new v25 now.

New in v25:

* Fixed a regression with parallel index scans caused by the improved
scheduling logic added by
0002-Improve-nbtree-SAOP-primitive-scan-scheduling.patch.

v24 did not account for how "firstPage=false" calls to _bt_readpage
might originate from _bt_first (not _bt_next) during parallel scans,
even during the first page for the parallel worker's primitive
scan/_bt_first call -- which made the heuristics added to
_bt_advance_array_keys do the wrong thing by not terminating primitive
scan based on faulty information. This was possible via the parallel
scan _bt_readnextpage "seized=true" path, which led to regressions. In
v24 we now pass "firstPage=true" whenever a call to _bt_readpage
happens through _bt_first, no matter the details (for the first
_bt_readpage call's page).

* The additional EXPLAIN ANALYZE logic (that shows "Index Searches:
N") added by 0001-Show-index-search-count-in-EXPLAIN-ANALYZE.patch has
been adjusted, and no longer divides by nloops.

I explain why dividing by nloops has some fairly bad consequences on
the thread I started for the quasi-independent enhancement to EXPLAIN
ANALYZE output:

https://postgr.es/m/CAH2-WzmebSkeKPGw7TEaNw9=Qx-X8fAnFw916Fd2V8VVqYqqaQ@mail.gmail.com

* Polished commit messages.

* Added more test coverage. The LOC covered percentage is now at just
over 90% for nbtutils.c. We now have coverage for almost all of the
new code that advances the scan's skip arrays, including code that
deals with NULL values that is seldom reached.

--
Peter Geoghegan

Attachment Content-Type Size
v25-0004-Lower-the-overhead-of-nbtree-runtime-skip-checks.patch application/x-patch 32.4 KB
v25-0006-DEBUG-Add-skip-scan-disable-GUCs.patch application/x-patch 4.4 KB
v25-0005-Apply-low-order-skip-key-in-_bt_first-more-often.patch application/x-patch 11.3 KB
v25-0002-Improve-nbtree-SAOP-primitive-scan-scheduling.patch application/x-patch 24.6 KB
v25-0003-Add-nbtree-skip-scan-optimizations.patch application/x-patch 177.2 KB
v25-0001-Show-index-search-count-in-EXPLAIN-ANALYZE.patch application/x-patch 53.1 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Sadeq Dousti 2025-02-23 19:38:45 psql \dh: List High-Level (Root) Tables and Indexes
Previous Message Daniel Gustafsson 2025-02-23 17:08:37 Re: [PoC] Federated Authn/z with OAUTHBEARER