From: | Kyotaro HORIGUCHI <horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)jp> |
---|---|
To: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Trigger information for auto_explain. |
Date: | 2014-01-14 09:25:07 |
Message-ID: | 20140114.182507.51576212.horiguchi.kyotaro@lab.ntt.co.jp |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hello,
Now explain can show trigger statistics (from when?).
=# create table t (a int, b int);
=# create or replace function hoge() returns trigger as 'begin new.b = new.a; return new; end;' language plpgsql;
=# create trigger ins_hoge before insert or update on t for each row execute procedure hoge();
Explain analyze shows trigger information.
=# explain analyze insert into t (select a from generate_series(0, 100) a);
| QUERY PLAN
|----------------------------------------------------------------
| Insert on t (cost=0.00..10.00 rows=1000 width=4) (actual time=2.712.....
| -> Function Scan on generate_series a (cost=0.00..10.00 rows=1000 width=4)
| (actual time=0.047..0.147 rows=101 loops=1)
| Trigger ins_hoge: time=1.881 calls=101
| Total runtime: 3.009 ms
On the other hand, auto_explain doesn't.
=# load auto_explain;
=# set auto_explain.log_min_duration = 0;
=# set auto_explain.log_analyze = 'yes';
=# insert into t (select a from generate_series(0, 100) a);
|LOG: duration: 2.871 ms plan:
| Query Text: insert into t (select a from generate_series(0, 100) a);
| Insert on t (cost=0.00..10.00 rows=1000 width=4)
| -> Function Scan on generate_series a (cost=0.00..10.00 ...
auto_explain will show trigger infos with this patch like this.
=# set auto_explain.log_triggers = 'yes';
=# insert into t (select a from generate_series(0, 100) a);
| LOG: duration: 2.098 ms plan:
| Query Text: insert into t (select a from generate_series(0, 100) a);
| Insert on t (cost=0.00..10.00 rows=1000 width=4) (actual time=2.097..2.097 rows=0 loops=1)
| -> Function Scan on generate_series a (cost=0.00..10.00 rows=1000 width=4) (actual time=0.044..0.123 rows=101 loops=1)
| Trigger ins_hoge: time=1.452 calls=101
This patch consists of two parts,
0001_expose_explain_triggers_v1_20140114.patch
Expose the code to print out trigger information currently
hidden in ExplainOnePlan().
0002_auto_explain_triggers_v1_20140114.patch
Enable auto_explain to output trigger information.
Documentation will be added later..
regards,
--
Kyotaro Horiguchi
NTT Open Source Software Center
Attachment | Content-Type | Size |
---|---|---|
0001_expose_explain_triggers_v1_20140114.patch | text/x-patch | 2.8 KB |
0002_auto_explain_triggers_v1_20140114.patch | text/x-patch | 1.4 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Dilip kumar | 2014-01-14 09:35:57 | Re: Case sensitive mode in windows build option |
Previous Message | Shigeru Hanada | 2014-01-14 09:24:45 | Re: inherit support for foreign tables |