Transform OR-clauses to SAOP's during index matching
Alexander Korotkov <akorotkov@postgresql.org>
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
Files
| Path | Change | +/− |
|---|---|---|
| src/backend/optimizer/path/indxpath.c | modified | +280 −4 |
| src/test/regress/expected/create_index.out | modified | +255 −15 |
| src/test/regress/expected/join.out | modified | +53 −4 |
| src/test/regress/expected/rowsecurity.out | modified | +7 −0 |
| src/test/regress/expected/stats_ext.out | modified | +12 −0 |
| src/test/regress/expected/uuid.out | modified | +31 −0 |
| src/test/regress/sql/create_index.sql | modified | +69 −0 |
| src/test/regress/sql/join.sql | modified | +9 −0 |
| src/test/regress/sql/rowsecurity.sql | modified | +1 −0 |
| src/test/regress/sql/stats_ext.sql | modified | +3 −0 |
| src/test/regress/sql/uuid.sql | modified | +12 −0 |
Discussion
- POC, WIP: OR-clause support for indexes 322 messages · 2015-12-26 → 2025-03-28