Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pg_track_optimizer.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "commands/explain_state.h"
#endif
#include "executor/executor.h"
#include "executor/instrument.h"
#include "funcapi.h"
#include "lib/dshash.h"
#include "miscadmin.h"
Expand Down Expand Up @@ -292,7 +293,11 @@ explain_ExecutorStart(QueryDesc *queryDesc, int eflags)
MemoryContext oldcxt;

oldcxt = MemoryContextSwitchTo(queryDesc->estate->es_query_cxt);
#if PG_VERSION_NUM >= 190000
queryDesc->totaltime = InstrAlloc(INSTRUMENT_ALL);
#else
queryDesc->totaltime = InstrAlloc(1, INSTRUMENT_ALL, false);
#endif
MemoryContextSwitchTo(oldcxt);
}
}
Expand Down
25 changes: 16 additions & 9 deletions plan_error.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,14 @@ prediction_walker(PlanState *pstate, void *context)
*/
foreach_node(SubPlanState, sps, pstate->subPlan)
{
Instrumentation *instr = sps->planstate->instrument;
double subplan_time;
double loop_factor;
double cost_factor;
#if PG_VERSION_NUM >= 190000
NodeInstrumentation *instr = sps->planstate->instrument;
#else
Instrumentation *instr = sps->planstate->instrument;
#endif
double subplan_time;
double loop_factor;
double cost_factor;

/*
* TODO:
Expand All @@ -76,7 +80,7 @@ prediction_walker(PlanState *pstate, void *context)

nloops = instr->nloops;
#if PG_VERSION_NUM >= 190000
subplan_time = INSTR_TIME_GET_MILLISEC(instr->total);
subplan_time = INSTR_TIME_GET_MILLISEC(instr->instr.total);
#else
subplan_time = instr->total * 1000.;
#endif
Expand Down Expand Up @@ -116,8 +120,8 @@ prediction_walker(PlanState *pstate, void *context)
InstrEndLoop(pstate->instrument);
nloops = pstate->instrument->nloops;
#if PG_VERSION_NUM >= 190000
node_time = INSTR_TIME_IS_ZERO(pstate->instrument->total) ? 0.0 :
INSTR_TIME_GET_MILLISEC(pstate->instrument->total);
node_time = INSTR_TIME_IS_ZERO(pstate->instrument->instr.total) ? 0.0 :
INSTR_TIME_GET_MILLISEC(pstate->instrument->instr.total);
#else
node_time = pstate->instrument->total * 1000.;
#endif
Expand Down Expand Up @@ -178,8 +182,11 @@ prediction_walker(PlanState *pstate, void *context)
*/
for (i = 0; i < pstate->worker_instrument->num_workers; i++)
{
Instrumentation *instr = &pstate->worker_instrument->instrument[i];

#if PG_VERSION_NUM >= 190000
NodeInstrumentation *instr = &pstate->worker_instrument->instrument[i];
#else
Instrumentation *instr = &pstate->worker_instrument->instrument[i];
#endif
if (instr->nloops <= 0.0)
{
/*
Expand Down
Loading