@@ -819,19 +819,6 @@ ExecParallelReinitialize(PlanState *planstate,
819819 /* Old workers must already be shut down */
820820 Assert (pei -> finished );
821821
822- /* Clear the instrumentation space from the last round. */
823- if (pei -> instrumentation )
824- {
825- Instrumentation * instrument ;
826- SharedExecutorInstrumentation * sh_instr ;
827- int i ;
828-
829- sh_instr = pei -> instrumentation ;
830- instrument = GetInstrumentationArray (sh_instr );
831- for (i = 0 ; i < sh_instr -> num_workers * sh_instr -> num_plan_nodes ; ++ i )
832- InstrInit (& instrument [i ], pei -> planstate -> state -> es_instrument );
833- }
834-
835822 /* Force parameters we're going to pass to workers to be evaluated. */
836823 ExecEvalParamExecParams (sendParams , estate );
837824
@@ -953,33 +940,21 @@ ExecParallelRetrieveInstrumentation(PlanState *planstate,
953940 for (n = 0 ; n < instrumentation -> num_workers ; ++ n )
954941 InstrAggNode (planstate -> instrument , & instrument [n ]);
955942
956- if (!planstate -> worker_instrument )
957- {
958- /*
959- * Allocate space for the per-worker detail.
960- *
961- * Worker instrumentation should be allocated in the same context as
962- * the regular instrumentation information, which is the per-query
963- * context. Switch into per-query memory context.
964- */
965- oldcontext = MemoryContextSwitchTo (planstate -> state -> es_query_cxt );
966- ibytes =
967- mul_size (instrumentation -> num_workers , sizeof (Instrumentation ));
968- planstate -> worker_instrument =
969- palloc (ibytes + offsetof(WorkerInstrumentation , instrument ));
970- MemoryContextSwitchTo (oldcontext );
971-
972- for (n = 0 ; n < instrumentation -> num_workers ; ++ n )
973- InstrInit (& planstate -> worker_instrument -> instrument [n ],
974- planstate -> state -> es_instrument );
975- }
943+ /*
944+ * Also store the per-worker detail.
945+ *
946+ * Worker instrumentation should be allocated in the same context as the
947+ * regular instrumentation information, which is the per-query context.
948+ * Switch into per-query memory context.
949+ */
950+ oldcontext = MemoryContextSwitchTo (planstate -> state -> es_query_cxt );
951+ ibytes = mul_size (instrumentation -> num_workers , sizeof (Instrumentation ));
952+ planstate -> worker_instrument =
953+ palloc (ibytes + offsetof(WorkerInstrumentation , instrument ));
954+ MemoryContextSwitchTo (oldcontext );
976955
977956 planstate -> worker_instrument -> num_workers = instrumentation -> num_workers ;
978-
979- /* Accumulate the per-worker detail. */
980- for (n = 0 ; n < instrumentation -> num_workers ; ++ n )
981- InstrAggNode (& planstate -> worker_instrument -> instrument [n ],
982- & instrument [n ]);
957+ memcpy (& planstate -> worker_instrument -> instrument , instrument , ibytes );
983958
984959 /* Perform any node-type-specific work that needs to be done. */
985960 switch (nodeTag (planstate ))
0 commit comments