From bb7085bc2fcc68ace9917cfc20c6b91d0acee89d Mon Sep 17 00:00:00 2001 From: aykutbozkurt Date: Wed, 23 Nov 2022 15:49:03 +0300 Subject: [PATCH] forcefully choose recursive plan for inner join btw recurring and nonrecurring parts --- .../distributed/planner/recursive_planning.c | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/backend/distributed/planner/recursive_planning.c b/src/backend/distributed/planner/recursive_planning.c index 9ce652499..93e6e95ca 100644 --- a/src/backend/distributed/planner/recursive_planning.c +++ b/src/backend/distributed/planner/recursive_planning.c @@ -664,6 +664,7 @@ RecursivelyPlanRecurringTupleOuterJoins(Node *node, Query *query, recursivePlanningContext); RecursivelyPlanRecurringTupleOuterJoins(joinExpr->rarg, query, recursivePlanningContext); + switch (joinExpr->jointype) { case JOIN_LEFT: @@ -846,19 +847,22 @@ RecursivelyPlanDistributedJoinNode(Node *distributedNode, Query *query, if (IsA(distributedNode, JoinExpr)) { /* - * XXX: This, for example, means that RecursivelyPlanRecurringTupleOuterJoins - * needs to plan inner side, i.e., INNER JOIN , - * of the following join: + * we forcefully choose recursive plan for nonrecurring part of join tree. + * We are here only if we cannot push down a join between recurring and non-recurring + * parts with the nonrecurring part consisting of INNER JOIN. * - * LEFT JOIN ( INNER JOIN ) - * - * However, this would require moving part of the join tree into a - * subquery but this implies that we need to rebuild the rtable and - * re-point all the Vars to the new rtable indexes. We have not - * implemented that yet. + * left join ( INNER JOIN ) + * We should recursively plan nonrecurring part i.e. (dist INNER JOIN dist) as a whole. */ - ereport(DEBUG4, (errmsg("recursive planner cannot plan distributed sub " - "join nodes yet"))); + JoinExpr *joinExpr = (JoinExpr *) distributedNode; + Node *leftNode = joinExpr->larg; + Node *rightNode = joinExpr->rarg; + + RecursivelyPlanDistributedJoinNode(leftNode, query, + recursivePlanningContext); + RecursivelyPlanDistributedJoinNode(rightNode, query, + recursivePlanningContext); + return; }