Skip to content

Commit df771e5

Browse files
author
Karina Litskevich
committed
Do not remove totaltime instrumentation from queryDesc
1 parent 3d8fd33 commit df771e5

File tree

1 file changed

+23
-30
lines changed

1 file changed

+23
-30
lines changed

src/backend/distributed/executor/multi_executor.c

Lines changed: 23 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -167,23 +167,19 @@ CitusExecutorRun(QueryDesc *queryDesc,
167167
*/
168168
executorBoundParams = queryDesc->params;
169169

170-
/*
171-
* We do some potentially time consuming operations ourself now before we hand off
172-
* control to postgres' executor. To make sure that time spent is accurately measured
173-
* we remove the totaltime instrumentation from the queryDesc. Instead we will start
174-
* and stop the instrumentation of the total time and put it back on the queryDesc
175-
* before returning (or rethrowing) from this function.
176-
*/
177-
Instrumentation *volatile totalTime = queryDesc->totaltime;
178-
queryDesc->totaltime = NULL;
179-
180170
PG_TRY();
181171
{
182172
ExecutorLevel++;
183173

184-
if (totalTime)
174+
/*
175+
* We do some potentially time consuming operations our self now before we hand of
176+
* control to postgres' executor. To make sure that time spent is accurately measured
177+
* we start and stop totaltime instrumentation from the queryDesc to mesure this
178+
* time consuming operations before postgres' executor.
179+
*/
180+
if (queryDesc->totaltime)
185181
{
186-
InstrStartNode(totalTime);
182+
InstrStartNode(queryDesc->totaltime);
187183
}
188184

189185
/*
@@ -202,13 +198,16 @@ CitusExecutorRun(QueryDesc *queryDesc,
202198
*/
203199
if (AlterTableConstraintCheck(queryDesc))
204200
{
205-
EState *estate = queryDesc->estate;
206-
207-
estate->es_processed = 0;
208-
209201
/* start and shutdown tuple receiver to simulate empty result */
210202
dest->rStartup(queryDesc->dest, CMD_SELECT, queryDesc->tupDesc);
211203
dest->rShutdown(dest);
204+
205+
queryDesc->estate->es_processed = 0;
206+
207+
if (queryDesc->totaltime)
208+
{
209+
InstrStopNode(queryDesc->totaltime, 0);
210+
}
212211
}
213212
else
214213
{
@@ -235,26 +234,25 @@ CitusExecutorRun(QueryDesc *queryDesc,
235234
/* postgres will switch here again and will restore back on its own */
236235
MemoryContextSwitchTo(oldcontext);
237236

238-
#if PG_VERSION_NUM >= PG_VERSION_18
237+
if (queryDesc->totaltime)
238+
{
239+
InstrStopNode(queryDesc->totaltime, 0);
240+
}
241+
242+
#if PG_VERSION_NUM >= PG_VERSION_18
239243

240244
/* PG18+ drops the “execute_once” argument */
241245
standard_ExecutorRun(queryDesc,
242246
direction,
243247
count);
244-
#else
248+
#else
245249

246250
/* PG17-: original four-arg signature */
247251
standard_ExecutorRun(queryDesc,
248252
direction,
249253
count,
250254
execute_once);
251-
#endif
252-
}
253-
254-
if (totalTime)
255-
{
256-
InstrStopNode(totalTime, queryDesc->estate->es_processed);
257-
queryDesc->totaltime = totalTime;
255+
#endif
258256
}
259257

260258
executorBoundParams = savedBoundParams;
@@ -282,11 +280,6 @@ CitusExecutorRun(QueryDesc *queryDesc,
282280
}
283281
PG_CATCH();
284282
{
285-
if (totalTime)
286-
{
287-
queryDesc->totaltime = totalTime;
288-
}
289-
290283
executorBoundParams = savedBoundParams;
291284
ExecutorLevel--;
292285

0 commit comments

Comments
 (0)