diff --git a/contrib/auto_explain/auto_explain.c b/contrib/auto_explain/auto_explain.c index 4ccd2aa..6f547b1 100644 --- a/contrib/auto_explain/auto_explain.c +++ b/contrib/auto_explain/auto_explain.c @@ -325,7 +325,7 @@ explain_ExecutorEnd(QueryDesc *queryDesc) es->verbose = auto_explain_log_verbose; es->buffers = (es->analyze && auto_explain_log_buffers); es->timing = (es->analyze && auto_explain_log_timing); - es->summary = es->analyze; + es->summary = es->analyze || es->summary; es->format = auto_explain_log_format; ExplainBeginOutput(es); diff --git a/src/backend/commands/explain.c b/src/backend/commands/explain.c index 0a669d9..f603f6e 100644 --- a/src/backend/commands/explain.c +++ b/src/backend/commands/explain.c @@ -167,6 +167,8 @@ ExplainQuery(ParseState *pstate, ExplainStmt *stmt, const char *queryString, timing_set = true; es->timing = defGetBoolean(opt); } + else if (strcmp(opt->defname, "summary") == 0) + es->summary = defGetBoolean(opt); else if (strcmp(opt->defname, "format") == 0) { char *p = defGetString(opt); @@ -208,8 +210,8 @@ ExplainQuery(ParseState *pstate, ExplainStmt *stmt, const char *queryString, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("EXPLAIN option TIMING requires ANALYZE"))); - /* currently, summary option is not exposed to users; just set it */ - es->summary = es->analyze; + /* always print summary when analyze is requested */ + es->summary = es->analyze || es->summary; /* * Parse analysis was done already, but we still have to run the rule @@ -550,7 +552,8 @@ ExplainOnePlan(PlannedStmt *plannedstmt, IntoClause *into, ExplainState *es, totaltime += elapsed_time(&starttime); - if (es->summary) + /* Execution time matters only when analyze is requested */ + if (es->summary && es->analyze) { if (es->format == EXPLAIN_FORMAT_TEXT) appendStringInfo(es->str, "Execution time: %.3f ms\n",