hawq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nh...@apache.org
Subject [3/4] incubator-hawq git commit: HAWQ-161. Port GPDB planner fixes to HAWQ Planner generated unnecessary motion node for nested subplan which scan catalog table.
Date Wed, 20 Jan 2016 20:16:13 GMT
HAWQ-161. Port GPDB planner fixes to HAWQ
Planner generated unnecessary motion node for nested subplan which scan catalog table.


Project: http://git-wip-us.apache.org/repos/asf/incubator-hawq/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-hawq/commit/0f6beb62
Tree: http://git-wip-us.apache.org/repos/asf/incubator-hawq/tree/0f6beb62
Diff: http://git-wip-us.apache.org/repos/asf/incubator-hawq/diff/0f6beb62

Branch: refs/heads/master
Commit: 0f6beb62fa1b14a8ca1e8054c75345625cfb4464
Parents: ada7919
Author: Kenan Yao <kyao@pivotal.io>
Authored: Thu Nov 12 15:13:16 2015 -0800
Committer: Noa Horn <nhorn@pivotal.io>
Committed: Wed Jan 20 12:15:52 2016 -0800

----------------------------------------------------------------------
 src/backend/cdb/cdbllize.c           | 21 +++++++++++++--------
 src/backend/optimizer/plan/setrefs.c |  1 +
 2 files changed, 14 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/0f6beb62/src/backend/cdb/cdbllize.c
----------------------------------------------------------------------
diff --git a/src/backend/cdb/cdbllize.c b/src/backend/cdb/cdbllize.c
index 4d58b6b..59a59d8 100644
--- a/src/backend/cdb/cdbllize.c
+++ b/src/backend/cdb/cdbllize.c
@@ -329,7 +329,6 @@ typedef struct ParallelizeCorrelatedPlanWalkerContext
 	Movement movement; /* What is the final movement necessary? Is it gather or broadcast */
 	List *rtable; /* rtable from the global context */
 	bool subPlanDistributed; /* is original subplan distributed */
-	bool subPlanHasMotion;/* is original subplan has motion already  */
 } ParallelizeCorrelatedPlanWalkerContext;
 
 /**
@@ -416,12 +415,20 @@ Plan *materialize_subplan(PlannerInfo *root, Plan *subplan)
 	return mat;
 }
 
+/* *
+ * Not listing every node type here, if further bug found due to not updating flow
+ * after cdbparallelize, just simply add that node type here.
+ * */
 static Node *ParallelizeCorrelatedSubPlanUpdateFlowMutator(Node *node)
 {
 	Assert(is_plan_node(node));
 	switch (nodeTag(node))
 	{
 		case T_Agg:
+		case T_Window:
+		case T_Sort:
+		case T_Material:
+		case T_Limit:
 		case T_Result:
 		{
 			if(((Plan *)node)->lefttree && ((Plan *)node)->lefttree->flow)
@@ -501,11 +508,8 @@ static Node* ParallelizeCorrelatedSubPlanMutator(Node *node, ParallelizeCorrelat
 		 * unnest(array[typoutput, typsend]) from pg_type) then 'upg_catalog.'
 		 * else 'pg_catalog.' end) FROM pg_proc p;
 		 **/
-		if(!ctx->subPlanHasMotion)
-		{
-			if(!scanPlan->flow || scanPlan->flow->flotype == FLOW_REPLICATED)
-				return (Node *)node;
-		}
+		if(scanPlan->flow && (scanPlan->flow->locustype == CdbLocusType_Entry))
+			return (Node *)node;
 
 		/**
 		 * Steps:
@@ -663,7 +667,6 @@ static Node* ParallelizeCorrelatedSubPlanMutator(Node *node, ParallelizeCorrelat
 	 */
 	if (IsA(node, Motion))
 	{
-		ctx->subPlanHasMotion = true;
 		Plan *plan = (Plan *) node;
 		node = (Node *) plan->lefttree;
 		Assert(node);
@@ -671,6 +674,9 @@ static Node* ParallelizeCorrelatedSubPlanMutator(Node *node, ParallelizeCorrelat
 	}
 
 	Node * result = plan_tree_mutator(node, ParallelizeCorrelatedSubPlanMutator, ctx);
+	/* *
+	 * Update the flow of the current plan node.
+	 * */
 	if(is_plan_node(node))
 		return ParallelizeCorrelatedSubPlanUpdateFlowMutator(result);
 	return result;
@@ -685,7 +691,6 @@ Plan* ParallelizeCorrelatedSubPlan(PlannerInfo *root, SubPlan *spExpr,
Plan *pla
 	ctx.base.node = (Node *) root;
 	ctx.movement = m;
 	ctx.subPlanDistributed = subPlanDistributed;
-	ctx.subPlanHasMotion = false;
 	ctx.sp = spExpr;
 	ctx.rtable = root->glob->finalrtable;
 	return (Plan *) ParallelizeCorrelatedSubPlanMutator((Node *) plan, &ctx);

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/0f6beb62/src/backend/optimizer/plan/setrefs.c
----------------------------------------------------------------------
diff --git a/src/backend/optimizer/plan/setrefs.c b/src/backend/optimizer/plan/setrefs.c
index afce5a5..2f70516 100644
--- a/src/backend/optimizer/plan/setrefs.c
+++ b/src/backend/optimizer/plan/setrefs.c
@@ -2528,6 +2528,7 @@ cdb_insert_result_node(PlannerGlobal *glob, Plan *plan, int rtoffset)
 	
     /* Reattach the Flow node. */
     resultplan->flow = flow;
+    plan->flow = flow;
 	
     return resultplan;
 }                               /* cdb_insert_result_node */


Mime
View raw message