pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: maksim <m.milyutin@postgrespro.ru>
To: pgsql-hackers@postgresql.org
Subject: Fwd: [BUG] Print timing statistics of trigger execution under turned off timing option of EXPLAIN ANALYZE
Date: Fri, 12 Aug 2016 14:47:06 +0300
Message-ID: <081c0540-ecaa-bd29-3fd2-6358f3b359a9@postgrespro.ru> (raw)
In-Reply-To: <57bd66d9-551f-3191-ff1f-88d554cac3b2@postgrespro.ru>
References: <57bd66d9-551f-3191-ff1f-88d554cac3b2@postgrespro.ru>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>

Hello, hackers!


At this moment EXPLAIN ANALYZE with turned off timing option after 
execution query that expires trigger prints time of total execution of 
trigger function:

postgres=# EXPLAIN (ANALYZE, timing false) insert INTO foo 
values(1000001, '');
                                 QUERY PLAN
--------------------------------------------------------------------------
  Insert on foo  (cost=0.00..0.01 rows=1 width=36) (actual rows=0 loops=1)
    ->  Result  (cost=0.00..0.01 rows=1 width=36) (actual rows=1 loops=1)
  Planning time: 0.038 ms
  Trigger unique_foo_c1:*/time=0.000/* calls=1
  Execution time: 340.766 ms
(5 rows)

My patch fixes this problem.

-- 
Maksim Milyutin
Postgres Professional:http://www.postgrespro.com
Russian Postgres Company

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Attachments:

trigger_timing.patch (text/x-patch, 1.1K) download diff --git a/src/backend/commands/explain.c b/src/backend/commands/explain.c index dbd27e5..808e23e 100644 --- a/src/backend/commands/explain.c +++ b/src/backend/commands/explain.c @@ -698,8 +698,11 @@ report_triggers(ResultRelInfo *rInfo, bool show_relname, ExplainState *es) appendStringInfo(es->str, " for constraint %s", conname); if (show_relname) appendStringInfo(es->str, " on %s", relname); - appendStringInfo(es->str, ": time=%.3f calls=%.0f\n", - 1000.0 * instr->total, instr->ntuples); + if (es->timing) + appendStringInfo(es->str, ": time=%.3f calls=%.0f\n", + 1000.0 * instr->total, instr->ntuples); + else + appendStringInfo(es->str, ": calls=%.0f\n", instr->ntuples); } else { @@ -707,7 +710,8 @@ report_triggers(ResultRelInfo *rInfo, bool show_relname, ExplainState *es) if (conname) ExplainPropertyText("Constraint Name", conname, es); ExplainPropertyText("Relation", relname, es); - ExplainPropertyFloat("Time", 1000.0 * instr->total, 3, es); + if (es->timing) + ExplainPropertyFloat("Time", 1000.0 * instr->total, 3, es); ExplainPropertyFloat("Calls", instr->ntuples, 0, es); }

view thread (2+ messages)  latest in thread

Message-ID: <081c0540-ecaa-bd29-3fd2-6358f3b359a9@postgrespro.ru>
Permalink:  ../081c0540-ecaa-bd29-3fd2-6358f3b359a9@postgrespro.ru/
Also on:    postgresql.org/message-id/081c0540-ecaa-bd29-3fd2-6358f3b359a9@postgrespro.ru

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-hackers@postgresql.org
  Cc: m.milyutin@postgrespro.ru
  Subject: Re: Fwd: [BUG] Print timing statistics of trigger execution under turned off timing option of EXPLAIN ANALYZE
  In-Reply-To: <081c0540-ecaa-bd29-3fd2-6358f3b359a9@postgrespro.ru>
  References: <57bd66d9-551f-3191-ff1f-88d554cac3b2@postgrespro.ru> <081c0540-ecaa-bd29-3fd2-6358f3b359a9@postgrespro.ru>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox