PostgreSQL的 执行计划保存
2012-11-08 12:46
295 查看
开始
首先,要安装 auto_explain:
进入 contrib/auto_explain 目录,运行 gmake ,然后运行 gmake install
然后编辑 postgresql.conf ,加入如下两行:
再在postgresql.conf 中设置log:
验证:
启动 postgresql 以后,运行:
查看log:
[作者:技术者高健@博客园 mail: ]luckyjackgao@gmail.com ]
结束
首先,要安装 auto_explain:
进入 contrib/auto_explain 目录,运行 gmake ,然后运行 gmake install
然后编辑 postgresql.conf ,加入如下两行:
shared_preload_libraries = 'auto_explain' auto_explain.log_min_duration='0'
再在postgresql.conf 中设置log:
# - Where to Log - log_destination = 'csvlog' # Valid values are combinations of # stderr, csvlog, syslog, and eventlog, # depending on platform. csvlog # requires logging_collector to be on. # This is used when logging to stderr: logging_collector = on # Enable capturing of stderr and csvlog # into log files. Required to be on for # csvlogs. # (change requires restart)
验证:
启动 postgresql 以后,运行:
[postgres@localhost bin]$ ./psql psql (9.2.0) Type "help" for help. postgres=# select count(*) from employee; count ------- 1000 (1 row) postgres=# \q
查看log:
[作者:技术者高健@博客园 mail: ]luckyjackgao@gmail.com ]
[postgres@localhost pg_log]$ ll total 4 -rw------- 1 postgres postgres 768 Nov 8 11:01 postgresql-2012-11-08_110114.csv -rw------- 1 postgres postgres 0 Nov 8 11:01 postgresql-2012-11-08_110114.log [postgres@localhost pg_log]$ cat postgresql-2012-11-08_110114.csv |grep "scan" [postgres@localhost pg_log]$ cat postgresql-2012-11-08_110114.csv 2012-11-08 11:01:14.453 CST,,,7014,,509b207a.1b66,1,,2012-11-08 11:01:14 CST,,0,LOG,00000,"database system was shut down at 2012-11-08 11:00:39 CST",,,,,,,,,"" 2012-11-08 11:01:14.459 CST,,,7018,,509b207a.1b6a,1,,2012-11-08 11:01:14 CST,,0,LOG,00000,"autovacuum launcher started",,,,,,,,,"" 2012-11-08 11:01:14.460 CST,,,7012,,509b207a.1b64,1,,2012-11-08 11:01:14 CST,,0,LOG,00000,"database system is ready to accept connections",,,,,,,,,"" 2012-11-08 11:01:36.950 CST,"postgres","postgres",7022,"[local]",509b2084.1b6e,1,"SELECT",2012-11-08 11:01:24 CST,2/2,0,LOG,00000,"duration: 0.100 ms plan: Query Text: select count(*) from employee; Aggregate (cost=19.50..19.51 rows=1 width=0) -> Seq Scan on employee (cost=0.00..17.00 rows=1000 width=0)",,,,,,,,,"psql"
结束
相关文章推荐
- PostgreSQL SQL的性能调试方法 查看执行计划
- 启用sqlplus的explain功能,保存结果至文件,查看sql的执行计划
- PostgreSQL学习第十三篇 执行计划
- PostgreSQL SQL的性能调试方法3--查看执行计划
- postgresql 执行计划理解
- PostgreSQL 执行计划与实际成本的偏差
- postgresql 执行计划理解
- PostgreSQL(三)索引&执行计划
- PostgreSQL的执行计划分析
- PostgreSQL执行计划
- postgresql中执行计划
- PostgreSQL join where 条件不同 explain 执行计划的差别
- PostgreSQL SQL的性能调试方法3--查看执行计划
- PostgreSQL执行计划的解释
- PostgreSql查看执行计划及分表
- PostgreSQL执行计划的解释
- 对PostgreSQL Nested Loop 执行计划的初步学习
- 我对PostgreSQL 中 执行计划的处理范围的理解
- PostgreSQL的执行计划分析
- PostgreSQL环境中查看SQL执行计划示例