Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Udvmj-0006vL-Nk for pgsql-docs@arkaria.postgresql.org; Sun, 19 May 2013 05:03:53 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1Udvmi-0000Dx-Jw for pgsql-docs@arkaria.postgresql.org; Sun, 19 May 2013 05:03:52 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Udvmh-0000Dr-NY for pgsql-docs@postgresql.org; Sun, 19 May 2013 05:03:51 +0000 Received: from moutng.kundenserver.de ([212.227.126.171]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Udvmf-0003qw-ER for pgsql-docs@postgresql.org; Sun, 19 May 2013 05:03:51 +0000 Received: from [192.168.1.110] (mail.highperformancepostgresql.com [71.179.240.8]) by mrelayeu.kundenserver.de (node=mrbap2) with ESMTP (Nemesis) id 0MN62C-1UXJ0d0IBc-006wiy; Sun, 19 May 2013 07:03:47 +0200 Message-ID: <51985D31.1030705@2ndQuadrant.com> Date: Sun, 19 May 2013 01:03:45 -0400 From: Greg Smith User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:14.0) Gecko/20120713 Thunderbird/14.0 MIME-Version: 1.0 To: pgsql-docs Subject: Clarify TIMING OFF behavior Content-Type: multipart/mixed; boundary="------------030400060101080808050004" X-Provags-ID: V02:K0:csLaCPjnUTXCSZWVk7t3eP+Wkbhk1TAVohabfGUZLcf BUTcop87hRm3+Jbt2jm/IL3m287Y/nY+/hOQedyfEy4cl/b0Mp +/zEJ5bNjJFJVkBLtX5LB8mfaaWkYQTLTmZ4cfgRRPwCrLz4M/ 0BXBUMWRugBIcyAkNZO/9KsMGNGi5pS9XgqaRKkwyN9BrjaXDq P0kkmN7GFPgUx7gKguxkwAmXQ1K/PVA6xP+Zpr2sOpejewjwHe 5vX7hOtcdpU9uc1k1q0Xd9rFqcV++2izOjh6nwN3vdwXJqDKRU UrLUL8L5IC8aFBaTWJ5LLyKQsHoUU5YHqkTxG7A+/VQm4PQlhV xNBeeZNgGlrh7Y4xWv20= X-Pg-Spam-Score: 0.8 (/) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-docs Precedence: bulk Sender: pgsql-docs-owner@postgresql.org This is a multi-part message in MIME format. --------------030400060101080808050004 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit While chatting in #pedant today, I noticed that it's not clear that EXPLAIN (ANALYZE ON, TIMING OFF) will still collect the total runtime of the statement. Attached patch clarifies that. It also comments why the related code runs INSTR_TIME_SET_CURRENT in all cases. That's actually how I noticed that--a read through explain.c now could rightly wonder "why is it still collecting that bit of time info when TIMING is off?" There's an argument possible here that a third TIMING option besides ON/OFF should really exist, one that really doesn't do any timing at all. I don't think enough use cases for that exist to justify coding it. The low overhead combination I've wanted for a while is EXPLAIN (ANALYZE ON, BUFFERS ON, TIMING OFF), and that works. -- Greg Smith 2ndQuadrant US greg@2ndQuadrant.com Baltimore, MD PostgreSQL Training, Services, and 24x7 Support www.2ndQuadrant.com --------------030400060101080808050004 Content-Type: text/plain; charset=UTF-8; x-mac-type="0"; x-mac-creator="0"; name="timing-off-clarify.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="timing-off-clarify.patch" diff --git a/doc/src/sgml/ref/explain.sgml b/doc/src/sgml/ref/explain.sgml index 1f35a1d..627119b 100644 --- a/doc/src/sgml/ref/explain.sgml +++ b/doc/src/sgml/ref/explain.sgml @@ -186,7 +186,8 @@ ROLLBACK; The overhead of repeatedly reading the system clock can slow down the query significantly on some systems, so it may be useful to set this parameter to FALSE when only actual row counts, and not - exact times, are needed. + exact times, are needed. Running time of the entire statement is always + collected, even when node level timing is turned off with this option. This parameter may only be used when ANALYZE is also enabled. It defaults to TRUE. diff --git a/src/backend/commands/explain.c b/src/backend/commands/explain.c index 38ce0ef..90fc727 100644 --- a/src/backend/commands/explain.c +++ b/src/backend/commands/explain.c @@ -414,6 +414,10 @@ ExplainOnePlan(PlannedStmt *plannedstmt, IntoClause *into, ExplainState *es, if (es->buffers) instrument_option |= INSTRUMENT_BUFFERS; + /* + * Always collect timing for the entire statement, even when + * node level timing is off. + */ INSTR_TIME_SET_CURRENT(starttime); /* --------------030400060101080808050004 Content-Type: text/plain Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 -- Sent via pgsql-docs mailing list (pgsql-docs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-docs --------------030400060101080808050004--