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: Transform OR-clauses to SAOP's during index matching
Date: Sun, 24 Nov 2024 00:00:22 +0000
Message-ID: <E1tF034-003F0S-R1@gemulon.postgresql.org> (raw)

Transform OR-clauses to SAOP's during index matching

This commit makes match_clause_to_indexcol() match
"(indexkey op C1) OR (indexkey op C2) ... (indexkey op CN)" expression
to the index while transforming it into "indexkey op ANY(ARRAY[C1, C2, ...])"
(ScalarArrayOpExpr node).

This transformation allows handling long OR-clauses with single IndexScan
avoiding diving them into a slower BitmapOr.

We currently restrict Ci to be either Const or Param to apply this
transformation only when it's clearly beneficial.  However, in the future,
we might switch to a liberal understanding of constants, as it is in other
cases.

Discussion: https://postgr.es/m/567ED6CA.2040504%40sigaev.ru
Author: Alena Rybakina, Andrey Lepikhov, Alexander Korotkov
Reviewed-by: Peter Geoghegan, Ranier Vilela, Alexander Korotkov, Robert Haas
Reviewed-by: Jian He, Tom Lane, Nikolay Shaplov

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/d4378c0005e61b1bb78e88097ea6efcdddbe2d6e

Modified Files
--------------
src/backend/optimizer/path/indxpath.c      | 284 ++++++++++++++++++++++++++++-
src/test/regress/expected/create_index.out | 270 +++++++++++++++++++++++++--
src/test/regress/expected/join.out         |  57 +++++-
src/test/regress/expected/rowsecurity.out  |   7 +
src/test/regress/expected/stats_ext.out    |  12 ++
src/test/regress/expected/uuid.out         |  31 ++++
src/test/regress/sql/create_index.sql      |  69 +++++++
src/test/regress/sql/join.sql              |   9 +
src/test/regress/sql/rowsecurity.sql       |   1 +
src/test/regress/sql/stats_ext.sql         |   3 +
src/test/regress/sql/uuid.sql              |  12 ++
11 files changed, 732 insertions(+), 23 deletions(-)



Message-ID: <E1tF034-003F0S-R1@gemulon.postgresql.org>
Permalink:  ../E1tF034-003F0S-R1@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1tF034-003F0S-R1@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: Transform OR-clauses to SAOP's during index matching
  In-Reply-To: <E1tF034-003F0S-R1@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