Re: Problems with get_actual_variable_range's VISITED_PAGES_LIMIT - Mailing list pgsql-hackers

From Peter Geoghegan
Subject Re: Problems with get_actual_variable_range's VISITED_PAGES_LIMIT
Date
Msg-id CAH2-Wz=oN+4+YFkJ=PijR5srTjBefVZfgV6zz0PU40pu1ntxMQ@mail.gmail.com
Whole thread
In response to Re: Problems with get_actual_variable_range's VISITED_PAGES_LIMIT  (Peter Geoghegan <pg@bowt.ie>)
List pgsql-hackers
On Mon, Feb 9, 2026 at 8:27 PM Peter Geoghegan <pg@bowt.ie> wrote:
> On Mon, Feb 9, 2026 at 7:39 PM Tom Lane <tgl@sss.pgh.pa.us> 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+s8Lw@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



pgsql-hackers by date:

Previous
From: Peter Geoghegan
Date:
Subject: Re: index prefetching
Next
From: Peter Geoghegan
Date:
Subject: Re: Problems with get_actual_variable_range's VISITED_PAGES_LIMIT