Test code.
authorRobert Haas <[email protected]>
Thu, 22 Oct 2015 14:33:40 +0000 (10:33 -0400)
committerRobert Haas <[email protected]>
Wed, 28 Oct 2015 17:51:25 +0000 (18:51 +0100)
src/backend/access/transam/parallel.c
src/backend/commands/explain.c
src/backend/optimizer/plan/planner.c

index 171356f3d5f3aef71f2494e587140ff419726e42..fa0cb86e49680855c677d5a3a641709b19ae1fe6 100644 (file)
@@ -1080,7 +1080,9 @@ ParallelExtensionTrampoline(dsm_segment *seg, shm_toc *toc)
 static void
 ParallelErrorContext(void *arg)
 {
+#if 0
        errcontext("parallel worker, pid %d", *(int32 *) arg);
+#endif
 }
 
 /*
index 7fb8a1458dfa427d87b296a6f5d8768d8aac5170..12a59a356060bb3b21e4c0075b5701cca08b7daf 100644 (file)
@@ -798,6 +798,17 @@ ExplainNode(PlanState *planstate, List *ancestors,
        int                     save_indent = es->indent;
        bool            haschildren;
 
+       if (IsA(planstate, GatherState))
+       {
+               Gather *gather = (Gather *) plan;
+               if (gather->single_copy)
+               {
+                       ExplainNode(outerPlanState(planstate), ancestors, relationship,
+                                               plan_name, es);
+                       return;
+               }
+       }
+
        switch (nodeTag(plan))
        {
                case T_Result:
index c0db458ad00a82cddcccfb419ed61d3a3eea3b0e..34ce39c56aa4552c93611c83b23885f30d02a78b 100644 (file)
@@ -1889,7 +1889,12 @@ grouping_planner(PlannerInfo *root, double tuple_fraction)
                         */
                        bool            need_sort_for_grouping = false;
 
-                       result_plan = create_plan(root, best_path);
+                       /* Try to run it in a worker. */
+                       if (best_path->parallel_safe)
+                               best_path = (Path *)
+                                       create_single_copy_gather_path(root, final_rel,
+                                                                                                  best_path, NULL);
+
                        current_pathkeys = best_path->pathkeys;
 
                        /* Detect if we'll need an explicit sort for grouping */
@@ -1905,6 +1910,8 @@ grouping_planner(PlannerInfo *root, double tuple_fraction)
                                need_tlist_eval = true;
                        }
 
+                       result_plan = create_plan(root, best_path);
+
                        /*
                         * create_plan returns a plan with just a "flat" tlist of required
                         * Vars.  Usually we need to insert the sub_tlist as the tlist of