diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2014-10-15 18:50:13 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2014-10-15 18:50:13 -0400 |
commit | 90063a7612e2730f7757c2a80ba384bbe7e35c4b (patch) | |
tree | 2e106aa9065c7f8f5e9e1937252118a19c64da9d /src/backend/commands/explain.c | |
parent | 076d29a1eed5fe51fb2b25b98fcde9dd7c506902 (diff) | |
download | postgresql-90063a7612e2730f7757c2a80ba384bbe7e35c4b.tar.gz postgresql-90063a7612e2730f7757c2a80ba384bbe7e35c4b.zip |
Print planning time only in EXPLAIN ANALYZE, not plain EXPLAIN.
We've gotten enough push-back on that change to make it clear that it
wasn't an especially good idea to do it like that. Revert plain EXPLAIN
to its previous behavior, but keep the extra output in EXPLAIN ANALYZE.
Per discussion.
Internally, I set this up as a separate flag ExplainState.summary that
controls printing of planning time and execution time. For now it's
just copied from the ANALYZE option, but we could consider exposing it
to users.
Diffstat (limited to 'src/backend/commands/explain.c')
-rw-r--r-- | src/backend/commands/explain.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/backend/commands/explain.c b/src/backend/commands/explain.c index 387d263e873..3fcc1ddc69c 100644 --- a/src/backend/commands/explain.c +++ b/src/backend/commands/explain.c @@ -191,6 +191,9 @@ ExplainQuery(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; + /* * Parse analysis was done already, but we still have to run the rule * rewriter. We do not do AcquireRewriteLocks: we assume the query either @@ -431,7 +434,8 @@ ExplainOnePlan(PlannedStmt *plannedstmt, IntoClause *into, ExplainState *es, /* * We always collect timing for the entire statement, even when node-level - * timing is off, so we don't look at es->timing here. + * timing is off, so we don't look at es->timing here. (We could skip + * this if !es->summary, but it's hardly worth the complication.) */ INSTR_TIME_SET_CURRENT(starttime); @@ -493,7 +497,7 @@ ExplainOnePlan(PlannedStmt *plannedstmt, IntoClause *into, ExplainState *es, /* Create textual dump of plan tree */ ExplainPrintPlan(es, queryDesc); - if (es->costs && planduration) + if (es->summary && planduration) { double plantime = INSTR_TIME_GET_DOUBLE(*planduration); @@ -526,7 +530,7 @@ ExplainOnePlan(PlannedStmt *plannedstmt, IntoClause *into, ExplainState *es, totaltime += elapsed_time(&starttime); - if (es->analyze) + if (es->summary) { if (es->format == EXPLAIN_FORMAT_TEXT) appendStringInfo(es->str, "Execution time: %.3f ms\n", |