The auto_explain module provides a means for logging execution plans of slow statements automatically, without having to run EXPLAIN by hand. This is especially helpful for tracking down un-optimized queries in large applications.

https://www.postgresql.org/docs/current/static/auto-explain.html

postgresql.conf

shared_preload_libraries = 'auto_explain'

auto_explain.log_min_duration = 0 
auto_explain.log_analyze = true
auto_explain.log_verbose = true
auto_explain.log_buffers = true
auto_explain.log_buffers = true
auto_explain.log_timing = true
auto_explain.log_triggers = true

auto_explain.log_nested_statements = true

[root@test01 pg_log]# vim postgresql-2016-05-28_004047.csv

2016-05-28 00:41:23.990 CST,"postgres","postgres",7263,"[local]",574878a4.1c5f,3,"SELECT",2016-05-28 00:41:08 CST,2/3,0,LOG,00000,"duration: 0.808 ms plan:
Query Text: SELECT count(*)
FROM pg_class, pg_index
WHERE oid = indrelid AND indisunique;
Aggregate (cost=22.07..22.08 rows=1 width=0) (actual time=0.785..0.785 rows=1 loops=1)
Output: count(*)
Buffers: shared hit=46 read=1
-> Hash Join (cost=5.71..21.80 rows=109 width=0) (actual time=0.352..0.736 rows=109 loops=1)
Hash Cond: (pg_class.oid = pg_index.indrelid)
Buffers: shared hit=46 read=1
-> Index Only Scan using pg_class_oid_index on pg_catalog.pg_class (cost=0.15..12.81 rows=311 width=4) (actual time=0.088..0.285 rows=313 loops=1)
Output: pg_class.oid
Heap Fetches: 124
Buffers: shared hit=40 read=1
-> Hash (cost=4.20..4.20 rows=109 width=4) (actual time=0.187..0.187 rows=109 loops=1)
Output: pg_index.indrelid
Buckets: 1024 Batches: 1 Memory Usage: 12kB
Buffers: shared hit=3
-> Seq Scan on pg_catalog.pg_index (cost=0.00..4.20 rows=109 width=4) (actual time=0.008..0.094 rows=109 loops=1)
Output: pg_index.indrelid
Filter: pg_index.indisunique
Rows Removed by Filter: 11
Buffers: shared hit=3",,,,,,,,"explain_ExecutorEnd, auto_explain.c:333","psql.bin"
2016-05-28 00:41:23.990 CST,"postgres","postgres",7263,"[local]",574878a4.1c5f,4,"SELECT",2016-05-28 00:41:08 CST,2/0,0,LOG,00000,"duration: 5.327 ms",,,,,,,,"exec_simple_query, postgres.c:1174","psql.bin"

PostgreSQL auto_explain的更多相关文章

  1. postgresql常用命令

    1.createdb 数据库名称 产生数据库2.dropdb 数据库名称 删除数据库 3.CREATE USER 用户名称 创建用户4.drop User 用户名称 删除用户 5.SELECT use ...

  2. 使用pgstatspack分析PostgreSQL数据库性能

    pgstatspack [root@test01 soft]# wget http://pgfoundry.org/frs/download.php/3151/pgstatspack_version_ ...

  3. 在CentOS上编译安装PostgreSQL

    http://my.oschina.net/tashi/blog 第一步:准备阶段 获取必需软件包: CentOS中查看是否安装了某个软件的命令:rpm -qa | grep 软件名.which命令可 ...

  4. Postgresql 10 自带扩展模块功能说明

    adminpackadminpack提供了许多支持功能,pgAdmin 和其他管理和管理工具可以使用它们来提供其他功能,例如远程管理服务器日志文件.所有这些功能的使用仅限于超级用户. citext 该 ...

  5. PostgreSQL源代码中插件的使用

    如果编译数据库时使用了gmake world和gmake install-world, 所有的插件都会被安装, 那么就不需要再次安装了. 插件目录 contrib 进入要安装的插件目录, 例如 cd ...

  6. PostgreSQL+pgpooll+Keepalived双机HA方案

    PostgreSQL+pgpooll+Keepalived双机HA方案 (注:本文档中的所有操作在没有说明的情况下都应该使用postgres用户进行操作,postgres用户没有权限的操作方可采用ro ...

  7. postgresql 基本语法

    postgresql数据库创建/修改/删除等写入类代码语法总结: 1,创建库 2,创建/删除表 2.1 创建表 create table myTableName 2.2 如果表不存在则创建表 crea ...

  8. postgresql无法安装pldbgapi的问题

    要对函数进行调试需要安装插件pldbgapi,当初在windows上面的postgresql实例中执行了一下语句就安装上了: create extension pldbgapi; 但是在linux中执 ...

  9. ASP.NET MVC 使用 Petapoco 微型ORM框架+NpgSql驱动连接 PostgreSQL数据库

    前段时间在园子里看到了小蝶惊鸿 发布的有关绿色版的Linux.NET——“Jws.Mono”.由于我对.Net程序跑在Linux上非常感兴趣,自己也看了一些有关mono的资料,但是一直没有时间抽出时间 ...

随机推荐

  1. nignx的proxy_cache

    http段配置: #cache configclient_body_buffer_size 512k;proxy_connect_timeout 5;proxy_read_timeout 60;pro ...

  2. Euler's totient function

    https://en.wikipedia.org/wiki/Euler's_totient_function counts the positive integers up to a given in ...

  3. Anti-pattern

    https://en.wikipedia.org/wiki/Anti-pattern https://zh.wikipedia.org/wiki/反面模式 An anti-pattern is a c ...

  4. Java中常用的内存区域

    在Java中主要存在4块内存空间,这些内存空间的名称及作用如下. 1.  栈内存空间: 保存所有对象名称(更准确的说是保存了引用的堆内存空间的地址). 2.  堆内存空间: 保存每个对象的具体属性内容 ...

  5. 浅析C++的内存管理

    在C++中,内存分成5个区,他们分别是堆.栈.自由存储区.全局/ 静态存储区和常量存储区. 栈,就是那些由编译器在需要的时候分配,在不需要的时候自动清楚的变量的存储区.里面的变量通常是局部变量.函数参 ...

  6. 【转】Unity利用WWW http传输Json数据

    http://blog.csdn.net/h570768995/article/details/50386935 首先去下载LitJson.dll,放在Plugins 目录下: LitJson可以从下 ...

  7. 哈哈,好像swift 以后有可能用来开发安卓喔

    好像swift  以后有可能用来开发安卓喔,哈哈

  8. windows下Qt5.1.0配置android环境搭建 good

    1.首先下载好需要配置的软件: 1>Qt 5.1.0 for Android (Windows 32-bit, 716 MB)(Info)下载地址: http://qt-project.org/ ...

  9. Ubuntu+Redis主从配置

    软件环境: OS:ubuntu-12.04-desktop-amd64 Redis:redis-2.8.13.tar.gz TCL:tcl8.6.2-src.tar.gz VMware:vmware ...

  10. 再谈CocoaPods

    1. 简介 java语言的第三方库管理工具是Maven,Node.js的第三方库管理工具是npm,而ios的第三方库管理工具是CocoaPods. CocoaPods 的原理是将所有的依赖库都放到名为 ...