Re: Problems with get_actual_variable_range's VISITED_PAGES_LIMIT

From: Peter Geoghegan <pg(at)bowt(dot)ie>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, MARK CALLAGHAN <mdcallag(at)gmail(dot)com>, Tomas Vondra <tomas(at)vondra(dot)me>
Subject: Re: Problems with get_actual_variable_range's VISITED_PAGES_LIMIT
Date: 2026-03-10 21:00:48
Message-ID: CAH2-Wz=oN+4+YFkJ=PijR5srTjBefVZfgV6zz0PU40pu1ntxMQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Feb 9, 2026 at 8:27 PM Peter Geoghegan <pg(at)bowt(dot)ie> wrote:
> On Mon, Feb 9, 2026 at 7:39 PM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Geoghegan 2026-03-10 21:03:14 Re: Problems with get_actual_variable_range's VISITED_PAGES_LIMIT
Previous Message Peter Geoghegan 2026-03-10 20:57:35 Re: index prefetching