@@ -612,19 +612,6 @@ ExecParallelReinitialize(PlanState *planstate,
612
612
/* Old workers must already be shut down */
613
613
Assert (pei -> finished );
614
614
615
- /* Clear the instrumentation space from the last round. */
616
- if (pei -> instrumentation )
617
- {
618
- Instrumentation * instrument ;
619
- SharedExecutorInstrumentation * sh_instr ;
620
- int i ;
621
-
622
- sh_instr = pei -> instrumentation ;
623
- instrument = GetInstrumentationArray (sh_instr );
624
- for (i = 0 ; i < sh_instr -> num_workers * sh_instr -> num_plan_nodes ; ++ i )
625
- InstrInit (& instrument [i ], pei -> planstate -> state -> es_instrument );
626
- }
627
-
628
615
ReinitializeParallelDSM (pei -> pcxt );
629
616
pei -> tqueue = ExecParallelSetupTupleQueues (pei -> pcxt , true);
630
617
pei -> reader = NULL ;
@@ -712,33 +699,21 @@ ExecParallelRetrieveInstrumentation(PlanState *planstate,
712
699
for (n = 0 ; n < instrumentation -> num_workers ; ++ n )
713
700
InstrAggNode (planstate -> instrument , & instrument [n ]);
714
701
715
- if (!planstate -> worker_instrument )
716
- {
717
- /*
718
- * Allocate space for the per-worker detail.
719
- *
720
- * Worker instrumentation should be allocated in the same context as
721
- * the regular instrumentation information, which is the per-query
722
- * context. Switch into per-query memory context.
723
- */
724
- oldcontext = MemoryContextSwitchTo (planstate -> state -> es_query_cxt );
725
- ibytes =
726
- mul_size (instrumentation -> num_workers , sizeof (Instrumentation ));
727
- planstate -> worker_instrument =
728
- palloc (ibytes + offsetof(WorkerInstrumentation , instrument ));
729
- MemoryContextSwitchTo (oldcontext );
730
-
731
- for (n = 0 ; n < instrumentation -> num_workers ; ++ n )
732
- InstrInit (& planstate -> worker_instrument -> instrument [n ],
733
- planstate -> state -> es_instrument );
734
- }
702
+ /*
703
+ * Also store the per-worker detail.
704
+ *
705
+ * Worker instrumentation should be allocated in the same context as the
706
+ * regular instrumentation information, which is the per-query context.
707
+ * Switch into per-query memory context.
708
+ */
709
+ oldcontext = MemoryContextSwitchTo (planstate -> state -> es_query_cxt );
710
+ ibytes = mul_size (instrumentation -> num_workers , sizeof (Instrumentation ));
711
+ planstate -> worker_instrument =
712
+ palloc (ibytes + offsetof(WorkerInstrumentation , instrument ));
713
+ MemoryContextSwitchTo (oldcontext );
735
714
736
715
planstate -> worker_instrument -> num_workers = instrumentation -> num_workers ;
737
-
738
- /* Accumulate the per-worker detail. */
739
- for (n = 0 ; n < instrumentation -> num_workers ; ++ n )
740
- InstrAggNode (& planstate -> worker_instrument -> instrument [n ],
741
- & instrument [n ]);
716
+ memcpy (& planstate -> worker_instrument -> instrument , instrument , ibytes );
742
717
743
718
return planstate_tree_walker (planstate , ExecParallelRetrieveInstrumentation ,
744
719
instrumentation );
0 commit comments