Skip to content

Commit 0140a11

Browse files
committed
Fix thinko in new match_join_clauses_to_index() logic.
We don't need to constrain the other side of an indexable join clause to not be below an outer join; an example here is SELECT FROM t1 LEFT JOIN t2 ON t1.a = t2.b LEFT JOIN t3 ON t2.c = t3.d; We can consider an inner indexscan on t3.d using c = d as indexqual, even though t2.c is potentially nulled by a previous outer join. The comparable logic in orindxpath.c has always worked that way, but I was being overly cautious here.
1 parent 973e9fb commit 0140a11

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/backend/optimizer/path/indxpath.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1702,17 +1702,17 @@ match_join_clauses_to_index(PlannerInfo *root,
17021702
* outer join rules.
17031703
*
17041704
* Instead of considering required_relids, we ignore clauses for which
1705-
* any referenced rel is in nullable_relids; that means there's an
1706-
* outer join below the clause and so it can't be checked at the
1707-
* relation scan level.
1705+
* the indexed rel is in nullable_relids; that means there's an outer
1706+
* join below the clause and so it can't be checked at the relation
1707+
* scan level.
17081708
*
17091709
* Note: unlike create_or_index_quals(), we can accept clauses that
17101710
* are marked !is_pushed_down (ie they are themselves outer-join
17111711
* clauses). This is OK because any path generated with these clauses
17121712
* could only be used in the inside of a nestloop join, which will be
17131713
* the nullable side.
17141714
*/
1715-
if (bms_overlap(rinfo->clause_relids, rinfo->nullable_relids))
1715+
if (bms_overlap(rel->relids, rinfo->nullable_relids))
17161716
continue;
17171717

17181718
/* Potentially usable, so see if it matches the index or is an OR */

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy