* them to all the join cost estimation functions.
*
* Input parameters:
+ * joinrel: join relation under consideration
* outerrel: outer relation under consideration
* innerrel: inner relation under consideration
* jointype: if not JOIN_SEMI or JOIN_ANTI, we assume it's inner_unique
*/
void
compute_semi_anti_join_factors(PlannerInfo *root,
+ RelOptInfo *joinrel,
RelOptInfo *outerrel,
RelOptInfo *innerrel,
JoinType jointype,
*/
if (IS_OUTER_JOIN(jointype))
{
- Relids joinrelids = bms_union(outerrel->relids, innerrel->relids);
-
joinquals = NIL;
foreach(l, restrictlist)
{
RestrictInfo *rinfo = lfirst_node(RestrictInfo, l);
- if (!RINFO_IS_PUSHED_DOWN(rinfo, joinrelids))
+ if (!RINFO_IS_PUSHED_DOWN(rinfo, joinrel->relids))
joinquals = lappend(joinquals, rinfo);
}
}
break;
case JOIN_UNIQUE_OUTER:
extra.inner_unique = innerrel_is_unique(root,
+ joinrel->relids,
outerrel->relids,
innerrel,
JOIN_INNER,
break;
default:
extra.inner_unique = innerrel_is_unique(root,
+ joinrel->relids,
outerrel->relids,
innerrel,
jointype,
* for cost estimation. These will be the same for all paths.
*/
if (jointype == JOIN_SEMI || jointype == JOIN_ANTI || extra.inner_unique)
- compute_semi_anti_join_factors(root, outerrel, innerrel,
+ compute_semi_anti_join_factors(root, joinrel, outerrel, innerrel,
jointype, sjinfo, restrictlist,
&extra.semifactors);
List *clause_list);
static Oid distinct_col_search(int colno, List *colnos, List *opids);
static bool is_innerrel_unique_for(PlannerInfo *root,
+ Relids joinrelids,
Relids outerrelids,
RelOptInfo *innerrel,
JoinType jointype,
innerrel->joininfo);
/* Test whether the innerrel is unique for those clauses. */
- if (!innerrel_is_unique(root, sjinfo->min_lefthand, innerrel,
+ if (!innerrel_is_unique(root,
+ joinrelids, sjinfo->min_lefthand, innerrel,
JOIN_SEMI, restrictlist, true))
continue;
*
* We need an actual RelOptInfo for the innerrel, but it's sufficient to
* identify the outerrel by its Relids. This asymmetry supports use of this
- * function before joinrels have been built.
+ * function before joinrels have been built. (The caller is expected to
+ * also supply the joinrelids, just to save recalculating that.)
*
* The proof must be made based only on clauses that will be "joinquals"
* rather than "otherquals" at execution. For an inner join there's no
*/
bool
innerrel_is_unique(PlannerInfo *root,
+ Relids joinrelids,
Relids outerrelids,
RelOptInfo *innerrel,
JoinType jointype,
}
/* No cached information, so try to make the proof. */
- if (is_innerrel_unique_for(root, outerrelids, innerrel,
+ if (is_innerrel_unique_for(root, joinrelids, outerrelids, innerrel,
jointype, restrictlist))
{
/*
*/
static bool
is_innerrel_unique_for(PlannerInfo *root,
+ Relids joinrelids,
Relids outerrelids,
RelOptInfo *innerrel,
JoinType jointype,
List *restrictlist)
{
- Relids joinrelids = bms_union(outerrelids, innerrel->relids);
List *clause_list = NIL;
ListCell *lc;
extern void cost_qual_eval(QualCost *cost, List *quals, PlannerInfo *root);
extern void cost_qual_eval_node(QualCost *cost, Node *qual, PlannerInfo *root);
extern void compute_semi_anti_join_factors(PlannerInfo *root,
+ RelOptInfo *joinrel,
RelOptInfo *outerrel,
RelOptInfo *innerrel,
JoinType jointype,
extern bool query_supports_distinctness(Query *query);
extern bool query_is_distinct_for(Query *query, List *colnos, List *opids);
extern bool innerrel_is_unique(PlannerInfo *root,
- Relids outerrelids, RelOptInfo *innerrel,
+ Relids joinrelids, Relids outerrelids, RelOptInfo *innerrel,
JoinType jointype, List *restrictlist, bool force_cache);
/*