On 13/04/2016 19:17, Robert Haas wrote: > On Tue, Apr 12, 2016 at 6:31 PM, Julien Rouhaud > <julien.rouh...@dalibo.com> wrote: >> On 11/04/2016 22:53, Julien Rouhaud wrote: >>> On 11/04/2016 17:44, Robert Haas wrote: >>>> We should probably add the number of workers actually obtained to the >>>> EXPLAIN ANALYZE output. That's been requested before. >>> >>> If it's not too late for 9.6, it would be very great. >> >> Just in case I attach a patch to implement it. I'll add it to the next >> commitfest. > > I think we should go with "Workers Planned" and "Workers Launched", > capitalized exactly that way, and lose "Number Of". >
Fixed > I would be inclined to view this as a reasonable 9.6 cleanup of > parallel query, but other people may wish to construe things more > strictly than I would. > FWIW, I also see it as a reasonable cleanup. -- Julien Rouhaud http://dalibo.com - http://dalibo.org
diff --git a/src/backend/commands/explain.c b/src/backend/commands/explain.c index 713cd0e..379fc5c 100644 --- a/src/backend/commands/explain.c +++ b/src/backend/commands/explain.c @@ -1339,8 +1339,16 @@ ExplainNode(PlanState *planstate, List *ancestors, if (plan->qual) show_instrumentation_count("Rows Removed by Filter", 1, planstate, es); - ExplainPropertyInteger("Number of Workers", + ExplainPropertyInteger("Workers Planned", gather->num_workers, es); + if (es->analyze) + { + int nworkers; + + nworkers = ((GatherState *) planstate)->nworkers_launched; + ExplainPropertyInteger("Workers Launched", + nworkers, es); + } if (gather->single_copy) ExplainPropertyText("Single Copy", gather->single_copy ? "true" : "false", diff --git a/src/backend/executor/nodeGather.c b/src/backend/executor/nodeGather.c index 3f0ed69..3834ed6 100644 --- a/src/backend/executor/nodeGather.c +++ b/src/backend/executor/nodeGather.c @@ -166,6 +166,7 @@ ExecGather(GatherState *node) */ pcxt = node->pei->pcxt; LaunchParallelWorkers(pcxt); + node->nworkers_launched = pcxt->nworkers_launched; /* Set up tuple queue readers to read the results. */ if (pcxt->nworkers_launched > 0) diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h index dbec07e..ee4e189 100644 --- a/src/include/nodes/execnodes.h +++ b/src/include/nodes/execnodes.h @@ -1956,6 +1956,7 @@ typedef struct GatherState struct ParallelExecutorInfo *pei; int nreaders; int nextreader; + int nworkers_launched; struct TupleQueueReader **reader; TupleTableSlot *funnel_slot; bool need_to_scan_locally;
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers