PostgreSQL 使用anto_explain自动记录超时SQL的执行计划
1. auto_explain 模块简单介绍 备注: 4. 创建表测试下 postgres=# create table tb3(id integer,name character varying);
CREATE TABLE
postgres=# insert into tb3 select generate_series(1,100000),'john';
INSERT 0 100000
postgres=# create index idx_tb3_id on tb3 using btree (id);
CREATE INDEX
postgres=# select * from tb3 where id=10;
id | name ----+------
10 | john
(1 row)
查看cvs日志 2015-04-20 00:07:07.378 PDT,2343,553469d3.927,13,2015-04-19 19:52:03 PDT,0,LOG,00000,"checkpoint starting: time",""
2015-04-20 00:07:07.619 PDT,14,"checkpoint complete: wrote 3 buffers (0.0%); 0 transaction log file(s) added,0 removed,0 recycled; write=0.209 s,sync=0.005 s,total=0.240 s; sync files=3,longest=0.003 s,average=0.001 s",""
2015-04-20 00:27:07.923 PDT,"postgres",2350,"[local]",553469da.92e,20,"SELECT",2015-04-19 19:52:10 PDT,2/21,"duration: 24.106 ms plan: Query Text: select * from tb3 where id=10; Index Scan using idx_tb3_id on tb3 (cost=0.29..8.31 rows=1 width=9) Index Cond: (id = 10)","psql"
当执行查询后,PG的日志里记录了语句的PLAN具体信息。 参考:http://francs3.blog.163.com/blog/static/405767272011791573867/ (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |