Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Tweak EXPLAIN for parallel query to show workers launched.
authorRobert Haas <rhaas@postgresql.org>
Fri, 15 Apr 2016 15:49:41 +0000 (11:49 -0400)
committerRobert Haas <rhaas@postgresql.org>
Fri, 15 Apr 2016 15:52:18 +0000 (11:52 -0400)
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
src/backend/executor/nodeGather.c
src/include/nodes/execnodes.h

index 713cd0e3da8abbc1442c5357e76ee0fde8a1b499..379fc5c429e1607ba2b777f2a80240634aca99c9 100644 (file)
@@ -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",
index 3f0ed6963277bf5e8ef438580e2b4835c95c597d..3834ed678cb650fca7f6403d7399798ae45c3091 100644 (file)
@@ -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)
index dbec07e5a375cbf235feddf5dc6c8120f23bb53f..ee4e189689348fbe317d6a8910edffbbe5ec00ab 100644 (file)
@@ -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;