pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Peter Geoghegan <pg@bowt.ie>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Cc: MARK CALLAGHAN <mdcallag@gmail.com>
Cc: Tomas Vondra <tomas@vondra.me>
Subject: Re: Problems with get_actual_variable_range's VISITED_PAGES_LIMIT
Date: Mon, 09 Feb 2026 19:39:33 -0500
Message-ID: <3613043.1770683973@sss.pgh.pa.us> (raw)
In-Reply-To: <CAH2-Wzkt1WkKp4VRJu3qHfmKXc8W+XYv1RXg5d2d3fSvAeO=rg@mail.gmail.com>
References: <CAH2-Wzkt1WkKp4VRJu3qHfmKXc8W+XYv1RXg5d2d3fSvAeO=rg@mail.gmail.com>

Peter Geoghegan <pg@bowt.ie> writes:
> VISITED_PAGES_LIMIT counts heap page visits. But when there are many
> index tuples marked LP_DEAD, btgettuple will traverse
> indefinitely-many *index* pages before returning even a single tuple
> to the selfuncs.c caller.

Yup, that's a problem.

> 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.  For one thing,
it is likely that the extremal page is only partly filled, so that
there may be only a very small number of index entries that this
strategy would consider at all.

Maybe it would work to express the limit as number of dead index
entries we will skip past before failing?  I'd want a threshold of
maybe a thousand, but that would still work to bound the index AM's
work as well as the heap AM's.

> Testing of the patch posted to that other thead today shows that this
> is much more effective.

What definition of "effective" are you using?  It sounds like you are
putting zero weight on successfully obtaining an estimate, and I find
that approach quite unacceptable.

			regards, tom lane





view thread (12+ messages)  latest in thread

Message-ID: <3613043.1770683973@sss.pgh.pa.us>
Permalink:  ../3613043.1770683973@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/3613043.1770683973@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-hackers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, pg@bowt.ie, mdcallag@gmail.com, tomas@vondra.me
  Subject: Re: Problems with get_actual_variable_range's VISITED_PAGES_LIMIT
  In-Reply-To: <3613043.1770683973@sss.pgh.pa.us>
  References: <CAH2-Wzkt1WkKp4VRJu3qHfmKXc8W+XYv1RXg5d2d3fSvAeO=rg@mail.gmail.com> <3613043.1770683973@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox