mirror of
https://git.postgresql.org/git/postgresql.git
synced 2026-02-23 06:47:14 +08:00
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
This commit is contained in:
@ -1462,6 +1462,15 @@ select * from tenk1 a join tenk1 b on
|
||||
(a.unique1 = 1 and b.unique1 = 2) or
|
||||
((a.unique2 = 3 or a.unique2 = 7) and b.hundred = 4);
|
||||
|
||||
explain (costs off)
|
||||
select * from tenk1 a join tenk1 b on
|
||||
(a.unique1 = 1 and b.unique1 = 2) or
|
||||
((a.unique2 = 3 or a.unique2 = 7) and b.hundred = 4);
|
||||
explain (costs off)
|
||||
select * from tenk1 a join tenk1 b on
|
||||
(a.unique1 < 20 or a.unique1 = 3 or a.unique1 = 1 and b.unique1 = 2) or
|
||||
((a.unique2 = 3 or a.unique2 = 7) and b.hundred = 4);
|
||||
|
||||
--
|
||||
-- test placement of movable quals in a parameterized join tree
|
||||
--
|
||||
|
||||
Reference in New Issue
Block a user