On Mon, Feb 9, 2026 at 8:27 PM Peter Geoghegan <[email protected]> wrote: > On Mon, Feb 9, 2026 at 7:39 PM Tom Lane <[email protected]> wrote: > > > Proposed solution > > > ================= > > > > > Rather than counting heap page visits, I propose limiting the scan to > > > the extremal leaf page only. If the extremal index leaf page yields no > > > visible tuples, we give up immediately. The latest version of the > > > index prefetching patch [2] adds a WIP patch that does just that. > > > > I think that's throwing the baby out with the bathwater. In exchange > > for a tight limit on planner time expended, you have an enormously > > increased chance of getting no useful data at all. > > It's true that I have only begun to examine how much of a risk this > is. It is still a WIP patch.
The latest revision of the index prefetching patch set (v12) has an improved mechanism that takes your concerns into account: https://postgr.es/m/CAH2-Wz=g=jtsydb4utb5su2zcvss7vbp+zmvvag6abocb+s...@mail.gmail.com The mechanism will now hold on longer. In practice, it will read up to 3 index leaf pages before giving up. The precise threshold is controlled by the selfuncs.c caller -- see v12-0009-Limit-get_actual_variable_range-to-scan-three-in.patch (unfortunately there's no easy way to break this out into an independent patch). -- Peter Geoghegan
