]> granicus.if.org Git - postgresql/commitdiff
Revert "Fix accumulation of parallel worker instrumentation."
authorRobert Haas <rhaas@postgresql.org>
Wed, 13 Dec 2017 20:19:28 +0000 (15:19 -0500)
committerRobert Haas <rhaas@postgresql.org>
Wed, 13 Dec 2017 20:19:28 +0000 (15:19 -0500)
This reverts commit 2c09a5c12a66087218c7f8cba269cd3de51b9b82.  Per
further discussion, that doesn't seem to be the best possible fix.

Discussion: http://postgr.es/m/CAA4eK1LW2aFKzY3=vwvc=t-juzPPVWP2uT1bpx_MeyEqnM+p8g@mail.gmail.com

src/backend/executor/execParallel.c
src/test/regress/expected/select_parallel.out
src/test/regress/sql/select_parallel.sql

index 558cb08b07e95d05b996ba3ac9f3018cde697405..d57cdbd4e153dc2e5211fd3a9ff3e95dbbcf6d01 100644 (file)
@@ -819,19 +819,6 @@ ExecParallelReinitialize(PlanState *planstate,
        /* Old workers must already be shut down */
        Assert(pei->finished);
 
-       /* Clear the instrumentation space from the last round. */
-       if (pei->instrumentation)
-       {
-               Instrumentation *instrument;
-               SharedExecutorInstrumentation *sh_instr;
-               int                     i;
-
-               sh_instr = pei->instrumentation;
-               instrument = GetInstrumentationArray(sh_instr);
-               for (i = 0; i < sh_instr->num_workers * sh_instr->num_plan_nodes; ++i)
-                       InstrInit(&instrument[i], pei->planstate->state->es_instrument);
-       }
-
        /* Force parameters we're going to pass to workers to be evaluated. */
        ExecEvalParamExecParams(sendParams, estate);
 
@@ -953,33 +940,21 @@ ExecParallelRetrieveInstrumentation(PlanState *planstate,
        for (n = 0; n < instrumentation->num_workers; ++n)
                InstrAggNode(planstate->instrument, &instrument[n]);
 
-       if (!planstate->worker_instrument)
-       {
-               /*
-                * Allocate space for the per-worker detail.
-                *
-                * Worker instrumentation should be allocated in the same context as
-                * the regular instrumentation information, which is the per-query
-                * context. Switch into per-query memory context.
-                */
-               oldcontext = MemoryContextSwitchTo(planstate->state->es_query_cxt);
-               ibytes =
-                       mul_size(instrumentation->num_workers, sizeof(Instrumentation));
-               planstate->worker_instrument =
-                       palloc(ibytes + offsetof(WorkerInstrumentation, instrument));
-               MemoryContextSwitchTo(oldcontext);
-
-               for (n = 0; n < instrumentation->num_workers; ++n)
-                       InstrInit(&planstate->worker_instrument->instrument[n],
-                                         planstate->state->es_instrument);
-       }
+       /*
+        * Also store the per-worker detail.
+        *
+        * Worker instrumentation should be allocated in the same context as the
+        * regular instrumentation information, which is the per-query context.
+        * Switch into per-query memory context.
+        */
+       oldcontext = MemoryContextSwitchTo(planstate->state->es_query_cxt);
+       ibytes = mul_size(instrumentation->num_workers, sizeof(Instrumentation));
+       planstate->worker_instrument =
+               palloc(ibytes + offsetof(WorkerInstrumentation, instrument));
+       MemoryContextSwitchTo(oldcontext);
 
        planstate->worker_instrument->num_workers = instrumentation->num_workers;
-
-       /* Accumulate the per-worker detail. */
-       for (n = 0; n < instrumentation->num_workers; ++n)
-               InstrAggNode(&planstate->worker_instrument->instrument[n],
-                                        &instrument[n]);
+       memcpy(&planstate->worker_instrument->instrument, instrument, ibytes);
 
        /* Perform any node-type-specific work that needs to be done. */
        switch (nodeTag(planstate))
index ff00d47f65bd6dc2335db7e57c5ccd52bbaaf43a..86a55922c878f92ebd90615a225cd5475969ef74 100644 (file)
@@ -465,28 +465,7 @@ select count(*) from bmscantest where a>1;
  99999
 (1 row)
 
--- test accumulation of stats for parallel node
 reset enable_seqscan;
-alter table tenk2 set (parallel_workers = 0);
-explain (analyze, timing off, summary off, costs off)
-       select count(*) from tenk1, tenk2 where tenk1.hundred > 1
-        and tenk2.thousand=0;
-                                QUERY PLAN                                
---------------------------------------------------------------------------
- Aggregate (actual rows=1 loops=1)
-   ->  Nested Loop (actual rows=98000 loops=1)
-         ->  Seq Scan on tenk2 (actual rows=10 loops=1)
-               Filter: (thousand = 0)
-               Rows Removed by Filter: 9990
-         ->  Gather (actual rows=9800 loops=10)
-               Workers Planned: 4
-               Workers Launched: 4
-               ->  Parallel Seq Scan on tenk1 (actual rows=1960 loops=50)
-                     Filter: (hundred > 1)
-                     Rows Removed by Filter: 40
-(11 rows)
-
-alter table tenk2 reset (parallel_workers);
 reset enable_indexscan;
 reset enable_hashjoin;
 reset enable_mergejoin;
index 1035d04d1a87303a7e5afb768c0922a9c37d079c..fb35ca33769e79262eb1da68831ec7c3d0e17067 100644 (file)
@@ -179,14 +179,7 @@ insert into bmscantest select r, 'fooooooooooooooooooooooooooooooooooooooooooooo
 create index i_bmtest ON bmscantest(a);
 select count(*) from bmscantest where a>1;
 
--- test accumulation of stats for parallel node
 reset enable_seqscan;
-alter table tenk2 set (parallel_workers = 0);
-explain (analyze, timing off, summary off, costs off)
-       select count(*) from tenk1, tenk2 where tenk1.hundred > 1
-        and tenk2.thousand=0;
-alter table tenk2 reset (parallel_workers);
-
 reset enable_indexscan;
 reset enable_hashjoin;
 reset enable_mergejoin;