Re: Bug in nbtree optimization to skip > operator comparisons (or < comparisons in backwards scans)
Pavel Borisov <pashkin.elfe@gmail.com>
From: Pavel Borisov <pashkin.elfe@gmail.com>
To: Alexander Korotkov <aekorotkov@gmail.com>
Cc: Peter Geoghegan <pg@bowt.ie>, Heikki Linnakangas <hlinnaka@iki.fi>, Matthias van de Meent <boekewurm+postgres@gmail.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2023-12-27T11:18:35Z
Lists: pgsql-hackers
Alexander, On Tue, 26 Dec 2023 at 23:35, Alexander Korotkov <aekorotkov@gmail.com> wrote: > Pavel, > > On Mon, Dec 25, 2023 at 8:32 PM Pavel Borisov <pashkin.elfe@gmail.com> > wrote: > > I've reviewed both patches: > > 0001 - is a pure refactoring replacing argument transfer from via struct > member to transfer explicitly as a function argument. It's justified by the > fact firstPage is localized only to several places. The patch looks simple > and good enough. > > > > 0002: > > continuescanPrechecked is semantically much better than previous > requiredMatchedByPrecheck which confused me earlier. Thanks! > > > > From the new comments, it looks a little bit hard to understand who does > what. Semantics "if caller told" in comments looks more clear to me. Could > you especially give attention to the comments: > > > > "If they wouldn't be matched, then the *continuescan flag would be set > for the current item and the last item on the page accordingly." > > "If the key is required for the opposite direction scan, we need to know > there was already at least one matching item on the page. For those keys." > > > > > Prechecking the value of the continuescan flag for the last item on the > > >+ * page (according to the scan direction). > > Maybe, in this case, it would be more clear like: "...(for backwards > scan it will be the first item on a page)" > > > > Otherwise the patch 0002 looks like a good fix for the bug to be pushed. > > Thank you for your review. I've revised comments to meet your suggestions. > Thank you for revised comments! I think they are good enough. Regards, Pavel
Commits
-
Fix an oversight in refactoring in 06b10f80ba4.
- b670b93a66fc 17.0 landed
-
Make RangeTblEntry dump order consistent
- b4080fa3dcf6 17.0 cited
-
Improvements and fixes for e0b1ee17dc
- 7e6fb5da41d8 17.0 landed
-
Remove BTScanOpaqueData.firstPage
- 06b10f80ba4d 17.0 landed
-
Optimize nbtree backward scan boundary cases.
- c9c0589fda0e 17.0 cited
-
Skip checking of scan keys required for directional scan in B-tree
- e0b1ee17dc3a 17.0 cited