mirror of
https://github.com/postgres/postgres.git
synced 2025-04-27 22:56:53 +03:00
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.
This commit is contained in:
parent
973e9fb294
commit
0140a11b9b
@ -1702,9 +1702,9 @@ match_join_clauses_to_index(PlannerInfo *root,
|
|||||||
* outer join rules.
|
* outer join rules.
|
||||||
*
|
*
|
||||||
* Instead of considering required_relids, we ignore clauses for which
|
* Instead of considering required_relids, we ignore clauses for which
|
||||||
* any referenced rel is in nullable_relids; that means there's an
|
* the indexed rel is in nullable_relids; that means there's an outer
|
||||||
* outer join below the clause and so it can't be checked at the
|
* join below the clause and so it can't be checked at the relation
|
||||||
* relation scan level.
|
* scan level.
|
||||||
*
|
*
|
||||||
* Note: unlike create_or_index_quals(), we can accept clauses that
|
* Note: unlike create_or_index_quals(), we can accept clauses that
|
||||||
* are marked !is_pushed_down (ie they are themselves outer-join
|
* are marked !is_pushed_down (ie they are themselves outer-join
|
||||||
@ -1712,7 +1712,7 @@ match_join_clauses_to_index(PlannerInfo *root,
|
|||||||
* could only be used in the inside of a nestloop join, which will be
|
* could only be used in the inside of a nestloop join, which will be
|
||||||
* the nullable side.
|
* the nullable side.
|
||||||
*/
|
*/
|
||||||
if (bms_overlap(rinfo->clause_relids, rinfo->nullable_relids))
|
if (bms_overlap(rel->relids, rinfo->nullable_relids))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* Potentially usable, so see if it matches the index or is an OR */
|
/* Potentially usable, so see if it matches the index or is an OR */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user