aboutsummaryrefslogtreecommitdiff
path: root/src/backend/optimizer/path/joinpath.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/optimizer/path/joinpath.c')
-rw-r--r--src/backend/optimizer/path/joinpath.c32
1 files changed, 21 insertions, 11 deletions
diff --git a/src/backend/optimizer/path/joinpath.c b/src/backend/optimizer/path/joinpath.c
index 39e2ddda906..c130d2f17f2 100644
--- a/src/backend/optimizer/path/joinpath.c
+++ b/src/backend/optimizer/path/joinpath.c
@@ -126,13 +126,15 @@ add_paths_to_joinrel(PlannerInfo *root,
*
* We have some special cases: for JOIN_SEMI and JOIN_ANTI, it doesn't
* matter since the executor can make the equivalent optimization anyway;
- * we need not expend planner cycles on proofs. For JOIN_UNIQUE_INNER, if
- * the LHS covers all of the associated semijoin's min_lefthand, then it's
- * appropriate to set inner_unique because the path produced by
- * create_unique_path will be unique relative to the LHS. (If we have an
- * LHS that's only part of the min_lefthand, that is *not* true.) For
- * JOIN_UNIQUE_OUTER, pass JOIN_INNER to avoid letting that value escape
- * this module.
+ * we need not expend planner cycles on proofs. For JOIN_UNIQUE_INNER, we
+ * must be considering a semijoin whose inner side is not provably unique
+ * (else reduce_unique_semijoins would've simplified it), so there's no
+ * point in calling innerrel_is_unique. However, if the LHS covers all of
+ * the semijoin's min_lefthand, then it's appropriate to set inner_unique
+ * because the path produced by create_unique_path will be unique relative
+ * to the LHS. (If we have an LHS that's only part of the min_lefthand,
+ * that is *not* true.) For JOIN_UNIQUE_OUTER, pass JOIN_INNER to avoid
+ * letting that value escape this module.
*/
switch (jointype)
{
@@ -145,12 +147,20 @@ add_paths_to_joinrel(PlannerInfo *root,
outerrel->relids);
break;
case JOIN_UNIQUE_OUTER:
- extra.inner_unique = innerrel_is_unique(root, outerrel, innerrel,
- JOIN_INNER, restrictlist);
+ extra.inner_unique = innerrel_is_unique(root,
+ outerrel->relids,
+ innerrel,
+ JOIN_INNER,
+ restrictlist,
+ false);
break;
default:
- extra.inner_unique = innerrel_is_unique(root, outerrel, innerrel,
- jointype, restrictlist);
+ extra.inner_unique = innerrel_is_unique(root,
+ outerrel->relids,
+ innerrel,
+ jointype,
+ restrictlist,
+ false);
break;
}