Re: Damage control for planner's get_actual_variable_endpoint() runaway

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Simon Riggs <simon(dot)riggs(at)enterprisedb(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, Jakub Wartak <jakub(dot)wartak(at)enterprisedb(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Damage control for planner's get_actual_variable_endpoint() runaway
Date: 2022-11-21 15:22:55
Message-ID: CA+TgmobZ+0qotbjwo4QEjWOybnOccynJmhWWWrn_WoB4UFahiQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Nov 21, 2022 at 10:14 AM Simon Riggs
<simon(dot)riggs(at)enterprisedb(dot)com> wrote:
> > > What we need is a solution that avoids reading an unbounded number of
> > > tuples under any circumstances. I previously suggested using
> > > SnapshotAny here, but Tom didn't like that. I'm not sure if there are
> > > safety issues there or if Tom was just concerned about the results
> > > being misleading. Either way, maybe there's some variant on that theme
> > > that could work. For instance, could we teach the index scan to stop
> > > if the first 100 tuples that it finds are all invisible? Or to reach
> > > at most 1 page, or at most 10 pages, or something?
> >
> > A hard limit on the number of index pages examined seems like it
> > might be a good idea.
>
> Good, that is what the patch does.

<looks at patch>

Oh, that's surprisingly simple. Nice!

Is there any reason to tie this into page costs? I'd be more inclined
to just make it a hard limit on the number of pages. I think that
would be more predictable and less prone to surprising (bad) behavior.
And to be honest I would be inclined to make it quite a small number.
Perhaps 5 or 10. Is there a good argument for going any higher?

--
Robert Haas
EDB: http://www.enterprisedb.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Simon Riggs 2022-11-21 15:30:31 Re: Damage control for planner's get_actual_variable_endpoint() runaway
Previous Message Ilya Gladyshev 2022-11-21 15:20:06 postgres_fdw binary protocol support