WIP: make EXPLAIN ANALYZE show time spent in triggers

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-patches(at)postgreSQL(dot)org
Subject: WIP: make EXPLAIN ANALYZE show time spent in triggers
Date: 2005-03-25 06:39:21
Message-ID: 20693.1111732761@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

The attached patch allows EXPLAIN ANALYZE to break out the time spent in
triggers when EXPLAINing a statement that can fire triggers. Formerly
this time was included in "Total runtime" but not otherwise accounted
for.

An example is

regression=# explain analyze delete from foo;
QUERY PLAN
--------------------------------------------------------------------------------------------------------
Seq Scan on foo (cost=0.00..172.70 rows=11770 width=6) (actual time=0.063..86.650 rows=10000 loops=1)
Trigger RI_ConstraintTrigger_60781: time=3899.609 calls=10000
Total runtime: 4218.309 ms
(3 rows)

The trigger display text probably still needs some work --- in
particular I'm wondering if RI triggers couldn't be displayed in some
more intelligent fashion than just the internal trigger name.

What I'm actually more interested in right now is comments on the
infrastructure changes. To make this work, I modified the executor's
ResultRelInfo structs to include provisions to store per-trigger
Instrumentation nodes, and changed AfterTriggerEndQuery to receive the
query's EState in which it could look up the ResultRelInfos. A nifty
side benefit is that the after-event trigger code doesn't have to open
result relations for itself anymore for non-deferred triggers: it can
use the executor's main copies of the relations. I had to change the
call order so that AfterTriggerEndQuery is called before instead of
after ExecutorEnd (because ExecutorEnd closes down all this state).
I don't see any downside to that, but am I missing something?

regards, tom lane

Attachment Content-Type Size
unknown_filename text/plain 33.8 KB

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Christopher Kings-Lynne 2005-03-25 06:48:51 Re: WIP: make EXPLAIN ANALYZE show time spent in triggers
Previous Message Christopher Kings-Lynne 2005-03-25 05:45:37 Update psql and pg_dump for new COPY api