Skip to content

Commit 6e35220

Browse files
Karina LitskevichGreen-Chan
authored andcommitted
Do not remove totaltime instrumentation from queryDesc
1 parent 5deaf9a commit 6e35220

1 file changed

Lines changed: 20 additions & 27 deletions

File tree

src/backend/distributed/executor/multi_executor.c

Lines changed: 20 additions & 27 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,13 +234,12 @@ CitusExecutorRun(QueryDesc *queryDesc,
235234
/* postgres will switch here again and will restore back on its own */
236235
MemoryContextSwitchTo(oldcontext);
237236

238-
standard_ExecutorRun(queryDesc, direction, count, execute_once);
239-
}
237+
if (queryDesc->totaltime)
238+
{
239+
InstrStopNode(queryDesc->totaltime, 0);
240+
}
240241

241-
if (totalTime)
242-
{
243-
InstrStopNode(totalTime, queryDesc->estate->es_processed);
244-
queryDesc->totaltime = totalTime;
242+
standard_ExecutorRun(queryDesc, direction, count, execute_once);
245243
}
246244

247245
executorBoundParams = savedBoundParams;
@@ -269,11 +267,6 @@ CitusExecutorRun(QueryDesc *queryDesc,
269267
}
270268
PG_CATCH();
271269
{
272-
if (totalTime)
273-
{
274-
queryDesc->totaltime = totalTime;
275-
}
276-
277270
executorBoundParams = savedBoundParams;
278271
ExecutorLevel--;
279272

0 commit comments

Comments
 (0)