|
|
|
|
@ -372,11 +372,7 @@ ExplainOneQuery(Query *query, int cursorOptions, |
|
|
|
|
PlannedStmt *plan; |
|
|
|
|
instr_time planstart, |
|
|
|
|
planduration; |
|
|
|
|
BufferUsage bufusage_start, |
|
|
|
|
bufusage; |
|
|
|
|
|
|
|
|
|
if (es->buffers) |
|
|
|
|
bufusage_start = pgBufferUsage; |
|
|
|
|
INSTR_TIME_SET_CURRENT(planstart); |
|
|
|
|
|
|
|
|
|
/* plan the query */ |
|
|
|
|
@ -385,16 +381,9 @@ ExplainOneQuery(Query *query, int cursorOptions, |
|
|
|
|
INSTR_TIME_SET_CURRENT(planduration); |
|
|
|
|
INSTR_TIME_SUBTRACT(planduration, planstart); |
|
|
|
|
|
|
|
|
|
/* calc differences of buffer counters. */ |
|
|
|
|
if (es->buffers) |
|
|
|
|
{ |
|
|
|
|
memset(&bufusage, 0, sizeof(BufferUsage)); |
|
|
|
|
BufferUsageAccumDiff(&bufusage, &pgBufferUsage, &bufusage_start); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* run it (if needed) and produce output */ |
|
|
|
|
ExplainOnePlan(plan, into, es, queryString, params, queryEnv, |
|
|
|
|
&planduration, (es->buffers ? &bufusage : NULL)); |
|
|
|
|
&planduration); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -487,8 +476,7 @@ ExplainOneUtility(Node *utilityStmt, IntoClause *into, ExplainState *es, |
|
|
|
|
void |
|
|
|
|
ExplainOnePlan(PlannedStmt *plannedstmt, IntoClause *into, ExplainState *es, |
|
|
|
|
const char *queryString, ParamListInfo params, |
|
|
|
|
QueryEnvironment *queryEnv, const instr_time *planduration, |
|
|
|
|
const BufferUsage *bufusage) |
|
|
|
|
QueryEnvironment *queryEnv, const instr_time *planduration) |
|
|
|
|
{ |
|
|
|
|
DestReceiver *dest; |
|
|
|
|
QueryDesc *queryDesc; |
|
|
|
|
@ -572,9 +560,6 @@ ExplainOnePlan(PlannedStmt *plannedstmt, IntoClause *into, ExplainState *es, |
|
|
|
|
/* Create textual dump of plan tree */ |
|
|
|
|
ExplainPrintPlan(es, queryDesc); |
|
|
|
|
|
|
|
|
|
if (es->summary && (planduration || bufusage)) |
|
|
|
|
ExplainOpenGroup("Planning", "Planning", true, es); |
|
|
|
|
|
|
|
|
|
if (es->summary && planduration) |
|
|
|
|
{ |
|
|
|
|
double plantime = INSTR_TIME_GET_DOUBLE(*planduration); |
|
|
|
|
@ -582,19 +567,6 @@ ExplainOnePlan(PlannedStmt *plannedstmt, IntoClause *into, ExplainState *es, |
|
|
|
|
ExplainPropertyFloat("Planning Time", "ms", 1000.0 * plantime, 3, es); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* Show buffer usage */ |
|
|
|
|
if (es->summary && bufusage) |
|
|
|
|
{ |
|
|
|
|
if (es->format == EXPLAIN_FORMAT_TEXT) |
|
|
|
|
es->indent++; |
|
|
|
|
show_buffer_usage(es, bufusage); |
|
|
|
|
if (es->format == EXPLAIN_FORMAT_TEXT) |
|
|
|
|
es->indent--; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (es->summary && (planduration || bufusage)) |
|
|
|
|
ExplainCloseGroup("Planning", "Planning", true, es); |
|
|
|
|
|
|
|
|
|
/* Print info about runtime of triggers */ |
|
|
|
|
if (es->analyze) |
|
|
|
|
ExplainPrintTriggers(es, queryDesc); |
|
|
|
|
|