pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alexander Korotkov <akorotkov@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Improvements and fixes for e0b1ee17dc
Date: Wed, 27 Dec 2023 12:35:22 +0000
Message-ID: <E1rIT86-00C9Ln-F2@gemulon.postgresql.org> (raw)

Improvements and fixes for e0b1ee17dc

e0b1ee17dc introduced optimization for matching B-tree scan keys required for
the directional scan.  However, it incorrectly assumed that all keys required
for opposite direction scan are satisfied by _bt_first().  It has been
illustrated that with multiple scan keys over the same column, a lesser one
(according to the scan direction) could win leaving the other one unsatisfied.

Instead of relying on _bt_first() this commit introduces code that memorizes
whether there was at least one match on the page.  If that's true we know that
keys required for opposite-direction scan are satisfied as soon as
corresponding values are not NULLs.

Also, this commit simplifies the description for the optimization of keys
required for the current direction scan.  Now the flag used for this is named
continuescanPrechecked and means exactly that *continuescan flag is known
to be true for the last item on the page.

Reported-by: Peter Geoghegan
Discussion: https://postgr.es/m/CAH2-Wzn0LeLcb1PdBnK0xisz8NpHkxRrMr3NWJ%2BKOK-WZ%2BQtTQ%40mail.gmail.com
Reviewed-by: Pavel Borisov

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/7e6fb5da41d8ee1bddcd5058b7204018ef68d193

Modified Files
--------------
src/backend/access/nbtree/nbtsearch.c | 42 ++++++++++++++++++++---------------
src/backend/access/nbtree/nbtutils.c  | 40 +++++++++++++++++++++------------
src/include/access/nbtree.h           |  2 +-
3 files changed, 51 insertions(+), 33 deletions(-)



Message-ID: <E1rIT86-00C9Ln-F2@gemulon.postgresql.org>
Permalink:  ../E1rIT86-00C9Ln-F2@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1rIT86-00C9Ln-F2@gemulon.postgresql.org

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: akorotkov@postgresql.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Improvements and fixes for e0b1ee17dc
  In-Reply-To: <E1rIT86-00C9Ln-F2@gemulon.postgresql.org>

* 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