diff options
author | Pavan Deolasee | 2015-08-18 11:33:53 +0000 |
---|---|---|
committer | Pavan Deolasee | 2015-08-18 11:33:53 +0000 |
commit | 724673cad46cb288b9ab66382be57b74119817b3 (patch) | |
tree | 3f3779f1264aa5b732263fde17ab4cf96dea4d94 | |
parent | d0ccee9a81e83af2612c37e3928f9e776302a0db (diff) |
Remember the restrictInfo clauses which were pushed down to inner parameterised
scans
We later use them to decide the actual subset of nodes where joins must be
pushed down. Without that we may push the plan to more nodes than necessary
because we would never look at the restrictInfo clauses which were removed
because of parameterised scans
-rw-r--r-- | src/backend/nodes/outfuncs.c | 1 | ||||
-rw-r--r-- | src/backend/optimizer/util/pathnode.c | 16 | ||||
-rw-r--r-- | src/include/nodes/relation.h | 4 |
3 files changed, 19 insertions, 2 deletions
diff --git a/src/backend/nodes/outfuncs.c b/src/backend/nodes/outfuncs.c index bda40f2f17..7c789ba7ad 100644 --- a/src/backend/nodes/outfuncs.c +++ b/src/backend/nodes/outfuncs.c @@ -2662,6 +2662,7 @@ _outJoinPathInfo(StringInfo str, const JoinPath *node) WRITE_NODE_FIELD(outerjoinpath); WRITE_NODE_FIELD(innerjoinpath); WRITE_NODE_FIELD(joinrestrictinfo); + WRITE_NODE_FIELD(movedrestrictinfo); } static void diff --git a/src/backend/optimizer/util/pathnode.c b/src/backend/optimizer/util/pathnode.c index b393b5021a..81ae3d26da 100644 --- a/src/backend/optimizer/util/pathnode.c +++ b/src/backend/optimizer/util/pathnode.c @@ -1015,6 +1015,7 @@ set_joinpath_distribution(PlannerInfo *root, JoinPath *pathnode) Distribution *outerd = pathnode->outerjoinpath->distribution; Distribution *targetd; List *alternate = NIL; + List *restrictClauses = NIL; /* Catalog join */ if (innerd == NULL && outerd == NULL) @@ -1102,6 +1103,10 @@ set_joinpath_distribution(PlannerInfo *root, JoinPath *pathnode) } + restrictClauses = list_copy(pathnode->joinrestrictinfo); + restrictClauses = list_concat(restrictClauses, + pathnode->movedrestrictinfo); + /* * This join is still allowed if inner and outer paths have * equivalent distribution and joined along the distribution keys. @@ -1129,7 +1134,7 @@ set_joinpath_distribution(PlannerInfo *root, JoinPath *pathnode) * Equivalence Class. * Try to figure out if such restriction exists. */ - foreach(lc, pathnode->joinrestrictinfo) + foreach(lc, restrictClauses) { RestrictInfo *ri = (RestrictInfo *) lfirst(lc); ListCell *emc; @@ -1345,7 +1350,7 @@ not_allowed_join: * 1. one argument is already a partitioning key of one subplan. * 2. restriction is cheaper to calculate */ - foreach(lc, pathnode->joinrestrictinfo) + foreach(lc, restrictClauses) { RestrictInfo *ri = (RestrictInfo *) lfirst(lc); @@ -2746,6 +2751,7 @@ create_nestloop_path(PlannerInfo *root, #ifdef XCP List *alternate; ListCell *lc; + List *mclauses = NIL; #endif Relids inner_req_outer = PATH_REQ_OUTER(inner_path); @@ -2771,6 +2777,10 @@ create_nestloop_path(PlannerInfo *root, inner_path->parent->relids, inner_and_outer)) jclauses = lappend(jclauses, rinfo); +#ifdef XCP + else + mclauses = lappend(mclauses, rinfo); +#endif } restrict_clauses = jclauses; } @@ -2792,6 +2802,8 @@ create_nestloop_path(PlannerInfo *root, pathnode->joinrestrictinfo = restrict_clauses; #ifdef XCP + pathnode->movedrestrictinfo = mclauses; + alternate = set_joinpath_distribution(root, pathnode); #endif final_cost_nestloop(root, pathnode, workspace, sjinfo, semifactors); diff --git a/src/include/nodes/relation.h b/src/include/nodes/relation.h index 4c284cfcba..f7df205fe1 100644 --- a/src/include/nodes/relation.h +++ b/src/include/nodes/relation.h @@ -1112,6 +1112,10 @@ typedef struct JoinPath List *joinrestrictinfo; /* RestrictInfos to apply to join */ +#ifdef XCP + List *movedrestrictinfo; /* RestrictInfos moved down to inner path */ +#endif + /* * See the notes for RelOptInfo and ParamPathInfo to understand why * joinrestrictinfo is needed in JoinPath, and can't be merged into the |