From 5702277ca97396384eaf5c58d582b79b9984ce73 Mon Sep 17 00:00:00 2001 From: Robert Haas Date: Fri, 15 Apr 2016 11:49:41 -0400 Subject: [PATCH] Tweak EXPLAIN for parallel query to show workers launched. The previous display was sort of confusing, because it didn't distinguish between the number of workers that we planned to launch and the number that actually got launched. This has already confused several people, so display both numbers and label them clearly. Julien Rouhaud, reviewed by me. --- src/backend/commands/explain.c | 10 +++++++++- src/backend/executor/nodeGather.c | 1 + src/include/nodes/execnodes.h | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/backend/commands/explain.c b/src/backend/commands/explain.c index 713cd0e3da..379fc5c429 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 3f0ed69632..3834ed678c 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 dbec07e5a3..ee4e189689 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;