Re: Damage control for planner's get_actual_variable_endpoint() runaway
Simon Riggs <simon.riggs@enterprisedb.com>
From: Simon Riggs <simon.riggs@enterprisedb.com>
To: Robert Haas <robertmhaas@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>, Alvaro Herrera <alvherre@alvh.no-ip.org>, Jakub Wartak <jakub.wartak@enterprisedb.com>, PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Date: 2022-11-21T15:30:31Z
Lists: pgsql-hackers
On Mon, 21 Nov 2022 at 15:23, Robert Haas <robertmhaas@gmail.com> wrote: > > On Mon, Nov 21, 2022 at 10:14 AM Simon Riggs > <simon.riggs@enterprisedb.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? +1, that makes the patch smaller and the behavior more predictable. (Just didn't want to do anything too simple, in case it looked like a kluge.) -- Simon Riggs http://www.EnterpriseDB.com/
Commits
-
YA attempt at taming worst-case behavior of get_actual_variable_range.
- b96a096dbc2b 11.19 landed
- ec10b6139c6d 12.14 landed
- bd06fe4dee63 14.7 landed
- 6e639267a534 13.10 landed
- 2debceed2947 15.2 landed
- 9c6ad5eaa957 16.0 landed
-
Improve performance of get_actual_variable_range with recently-dead tuples.
- 3ca930fc39cc 11.0 cited
-
Use SnapshotDirty rather than an active snapshot to probe index endpoints.
- fccebe421d0c 9.4.0 cited