>From 093af92ea74dc3a8c3a3eb1f323b0c9508816a71 Mon Sep 17 00:00:00 2001
From: Andres Freund <andres@anarazel.de>
Date: Wed, 4 Jun 2014 21:36:19 +0200
Subject: [PATCH 2/3] Don't print the execution time for EXPLAIN (ANALYZE,
 COSTS OFF).

The primary reason to use COSTS OFF for EXPLAIN is to get reproducable
output. Until now EXPLAIN with ANALYZE didn't generate reproducable
output, because it printed the execution time even with TIMING
OFF. Strangely sounding as it may be that actually makes sense because
TIMING OFF is there to reduce the timing overhead, not to produce
reproducable output.
---
 src/backend/commands/explain.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/backend/commands/explain.c b/src/backend/commands/explain.c
index 0d9663c..b2c39f5 100644
--- a/src/backend/commands/explain.c
+++ b/src/backend/commands/explain.c
@@ -492,6 +492,7 @@ ExplainOnePlan(PlannedStmt *plannedstmt, IntoClause *into, ExplainState *es,
 	/* Create textual dump of plan tree */
 	ExplainPrintPlan(es, queryDesc);
 
+	/* COSTS OFF is used for regression tests - don't print the plan time */
 	if (es->costs && planduration)
 	{
 		double		plantime = INSTR_TIME_GET_DOUBLE(*planduration);
@@ -525,7 +526,8 @@ ExplainOnePlan(PlannedStmt *plannedstmt, IntoClause *into, ExplainState *es,
 
 	totaltime += elapsed_time(&starttime);
 
-	if (es->analyze)
+	/* COSTS OFF is used for regression tests - don't print the execution time */
+	if (es->costs && es->analyze)
 	{
 		if (es->format == EXPLAIN_FORMAT_TEXT)
 			appendStringInfo(es->str, "Execution time: %.3f ms\n",
-- 
2.0.0.rc2.4.g1dc51c6.dirty

