PPAS下安装 pg_stat_statements过程记录
磨砺技术珠矶,践行数据之道,追求卓越价值
回到上一级页面: PostgreSQL统计信息索引页 回到顶级页面:PostgreSQL索引页
PostgreSQL中,如何安装pg_stat_statements,网上有很多这方面的论述。这里说说如何在PPAS下安装它:
实验一:首先,看是否可以不安装,直接拿来用:
[root@rhjp001 ~]# su - enterprisedb
-bash-3.2$ pwd
/opt/PostgresPlus/9.2AS
-bash-3.2$ ./bin/psql -d edb
psql (9.2.1.3)
"help" でヘルプを表示します. edb=# select count(*) from pg_stat_statements;
ERROR: pg_stat_statements must be loaded via shared_preload_libraries
edb=#
实验二:直接创建:
edb=# create extension pg_stat_statments;
ERROR: 拡張機能の制御ファイル "/opt/PostgresPlus/9.2AS/share/extension/pg_stat_statments.control" をオープンできませんでした: そのようなファイルやディレクトリはありません
edb=#
实验三:改配置文件后,再创建:
-bash-3.2$ pwd
/opt/PostgresPlus/9.2AS/data
-bash-3.2$ vim postgresql.conf
-bash-3.2$ cat postgresql.conf | grep preload
shared_preload_libraries = '$libdir/dbms_pipe,$libdir/edb_gen,pg_stat_statements'
#local_preload_libraries = ''
-bash-3.2$
重新启动后,创建,其实已经不用创建了。
[root@rhjp001 ~]# su - enterprisedb
-bash-3.2$ pwd
/opt/PostgresPlus/9.2AS
-bash-3.2$ ./bin/psql -d edb
psql (9.2.1.3)
"help" でヘルプを表示します. edb=# create extension pg_stat_statements;
ERROR: 拡張機能 "pg_stat_statements" はすでに存在します
edb=#
[root@rhjp001 ~]# su - enterprisedb
-bash-3.2$ ./bin/psql -d edb
psql (9.2.1.3)
"help" でヘルプを表示します. edb=# select count(*) from pg_stat_statements;
count
-------
47
(1 行) edb=#
也就是说,其实在PPAS安装好之后,如果想要使用 pg_stat_statements ,只要配置postgresql.conf的 shared_preload_libraries 就可以了。
卸载ppas,重新安装,然后再重新开始吧:
配置postgresql.conf:
把 shared_preload_libraries = '$libdir/dbms_pipe,$libdir/edb_gen'
改成:
shared_preload_libraries = '$libdir/dbms_pipe,$libdir/edb_gen,pg_stat_statements'
重新启动数据库: service ppas-9.2 restart
-bash-3.2$ ./bin/psql -d edb
psql (9.2.1.3)
"help" でヘルプを表示します. edb=# select count(*) from pg_stat_statements;
count
-------
42
(1 行) edb=#
这个pg_stat_statements,主要可以用于区分运行最慢的sql文:
例如:
edb=# \d pg_stat_statements;
ビュー "enterprisedb.pg_stat_statements"
列 | 型 | 修飾語
---------------------+------------------+--------
userid | oid |
dbid | oid |
query | text |
calls | bigint |
total_time | double precision |
rows | bigint |
shared_blks_hit | bigint |
shared_blks_read | bigint |
shared_blks_dirtied | bigint |
shared_blks_written | bigint |
local_blks_hit | bigint |
local_blks_read | bigint |
local_blks_dirtied | bigint |
local_blks_written | bigint |
temp_blks_read | bigint |
temp_blks_written | bigint |
blk_read_time | double precision |
blk_write_time | double precision | edb=#
查找最慢的10条sql文(这里用的是累计时间)
edb=# select * from pg_stat_statements order by total_time desc limit 10;
-[ RECORD 1 ]-------+------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------
userid | 10
dbid | 14000
query | drop extension pg_stat_statements;
calls | 2
total_time | 3099.557
rows | 0
shared_blks_hit | 673
shared_blks_read | 27
shared_blks_dirtied | 9
shared_blks_written | 0
local_blks_hit | 0
local_blks_read | 0
local_blks_dirtied | 0
local_blks_written | 0
temp_blks_read | 0
temp_blks_written | 0
blk_read_time | 0
blk_write_time | 0
-[ RECORD 2 ]-------+------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------
userid | 10
dbid | 14000
query | create database gaodb owner gao;
calls | 1
total_time | 2068.82
rows | 0
shared_blks_hit | 54
shared_blks_read | 4
shared_blks_dirtied | 7
shared_blks_written | 0
local_blks_hit | 0
local_blks_read | 0
local_blks_dirtied | 0
local_blks_written | 0
temp_blks_read | 0
temp_blks_written | 0
blk_read_time | 0
blk_write_time | 0
-[ RECORD 3 ]-------+------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------
userid | 10
dbid | 14000
query | CREATE TEMP TABLE pga_tmp_zombies(jagpid int4)
calls | 3
total_time | 1061.702
rows | 0
shared_blks_hit | 479
shared_blks_read | 109
shared_blks_dirtied | 37
shared_blks_written | 0
local_blks_hit | 0
local_blks_read | 0
local_blks_dirtied | 0
local_blks_written | 0
temp_blks_read | 0
temp_blks_written | 0
blk_read_time | 0
blk_write_time | 0
-[ RECORD 4 ]-------+------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------
userid | 10
dbid | 14000
query | SELECT count(*) As count, pg_backend_pid() AS pid FROM pg_class cl JOIN pg_na
mespace ns ON ns.oid=relnamespace WHERE relname=? AND nspname=?
calls | 3
total_time | 929.614
rows | 3
shared_blks_hit | 6
shared_blks_read | 15
shared_blks_dirtied | 0
shared_blks_written | 0
local_blks_hit | 0
local_blks_read | 0
local_blks_dirtied | 0
local_blks_written | 0
temp_blks_read | 0
temp_blks_written | 0
blk_read_time | 0
blk_write_time | 0
-[ RECORD 5 ]-------+------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------
userid | 10
dbid | 14000
query | SELECT COUNT(*) FROM pg_proc WHERE proname = ? AND pronamespace = (
SELECT oid FROM pg_namespace WHERE nspname = ?) AND prorettype = (SELECT oid ROM pg_type WHERE typnam e = ?) AND proargtypes = ?
calls | 3
total_time | 337.312
rows | 3
shared_blks_hit | 15
shared_blks_read | 15
shared_blks_dirtied | 0
shared_blks_written | 0
local_blks_hit | 0
local_blks_read | 0
local_blks_dirtied | 0
local_blks_written | 0
temp_blks_read | 0
temp_blks_written | 0
blk_read_time | 0
blk_write_time | 0
-[ RECORD 6 ]-------+------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------
userid | 10
dbid | 14000
query | SELECT pgagent.pgagent_schema_version()
calls | 3
total_time | 321.264
rows | 3
shared_blks_hit | 12
shared_blks_read | 12
shared_blks_dirtied | 0
shared_blks_written | 0
local_blks_hit | 0
local_blks_read | 0
local_blks_dirtied | 0
local_blks_written | 0
temp_blks_read | 0
temp_blks_written | 0
blk_read_time | 0
blk_write_time | 0
-[ RECORD 7 ]-------+------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------
userid | 10
dbid | 14000
query | DROP TABLE pga_tmp_zombies
calls | 3
total_time | 282.334
rows | 0
shared_blks_hit | 360
shared_blks_read | 21
shared_blks_dirtied | 0
shared_blks_written | 0
local_blks_hit | 0
local_blks_read | 0
local_blks_dirtied | 0
local_blks_written | 0
temp_blks_read | 0
temp_blks_written | 0
blk_read_time | 0
blk_write_time | 0
-[ RECORD 8 ]-------+------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------
userid | 10
dbid | 14000
query | create extension pg_stat_statements;
calls | 1
total_time | 155.641
rows | 0
shared_blks_hit | 585
shared_blks_read | 22
shared_blks_dirtied | 25
shared_blks_written | 0
local_blks_hit | 0
local_blks_read | 0
local_blks_dirtied | 0
local_blks_written | 0
temp_blks_read | 0
temp_blks_written | 0
blk_read_time | 0
blk_write_time | 0
-[ RECORD 9 ]-------+------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------
userid | 16684
dbid | 16685
query | create table gaotab(id integer);
calls | 1
total_time | 143.838
rows | 0
shared_blks_hit | 195
shared_blks_read | 59
shared_blks_dirtied | 21
shared_blks_written | 0
local_blks_hit | 0
local_blks_read | 0
local_blks_dirtied | 0
local_blks_written | 0
temp_blks_read | 0
temp_blks_written | 0
blk_read_time | 0
blk_write_time | 0
-[ RECORD 10 ]------+------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------
userid | 16684
dbid | 16685
query | select pg_available_extensions();
calls | 2
total_time | 92.16
rows | 100
shared_blks_hit | 5
shared_blks_read | 1
shared_blks_dirtied | 0
shared_blks_written | 0
local_blks_hit | 0
local_blks_read | 0
local_blks_dirtied | 0
local_blks_written | 0
temp_blks_read | 0
temp_blks_written | 0
blk_read_time | 0
blk_write_time | 0 edb=#
需要注意,只有管理员用户才可以看到这个视图。
回到上一级页面: PostgreSQL统计信息索引页 回到顶级页面:PostgreSQL索引页
磨砺技术珠矶,践行数据之道,追求卓越价值
PPAS下安装 pg_stat_statements过程记录的更多相关文章
- Linux5下安装MySQL过程记录
磨砺技术珠矶,践行数据之道,追求卓越价值 回到上一级页面: PostgreSQL杂记页 回到顶级页面:PostgreSQL索引页 [作者 高健@博客园 luckyjackgao@gmail. ...
- 在Linux下安装PHP过程中,编译时出现错误的解决办法
在Linux下安装PHP过程中,编译时出现configure: error: libjpeg.(a|so) not found 错误的解决办法 configure: error: libjpeg.(a ...
- xp硬盘安装Fedora14 过程记录及心得体会(fedora14 live版本680M 和fedora14 DVD版本3.2G的选择)
这次电脑奔溃了,奇怪的是直接ghost覆盖c盘竟然不中.之前电脑上硬盘安装的fedora14操作系统,也是双系统.不知道是不是这个问题,记得同学说过,在硬盘装fedora之后,要手动修改c盘隐藏的那个 ...
- FFmpeg在Linux下安装编译过程
转载请把头部出处链接和尾部二维码一起转载,本文出自:http://blog.csdn.net/hejjunlin/article/details/52402759 今天介绍下FFmpeg在Linux下 ...
- ubuntu下安装GTK过程
GTK的安装过程比较繁琐,以前也安装过,但没有记录下来,Google一下记录下来备用. 利用此方法成功在ubuntu12.04下安装GTK 2.24.10 1.安装gcc/g++/gdb/make 等 ...
- redhat6.0 安装ORACLE11GR2过程记录
vawaretools安装 我的是8.0vm 1,vm=>install vmtools 2,会在redhat里出现一个虚拟光驱图标. 3,复制里面的文件到root目录下. 4,解压缩文件 ta ...
- linux环境下安装qt过程
linux(虚拟机fedora9)环境下安装qt的过程主要是按照下面几网页上的教程完成的. http://mobile.51cto.com/symbian-272869.htm http://www. ...
- windows下安装python过程
方法一:如果你的电脑没有安装python,推荐使用anaconda(自带python环境,同时自带各种第三方库,可以省去很多麻烦) 这里提供两个下载地址:1,.官网https://www.anacon ...
- 记录下安装ES过程中遇到的错误及解决
1.集群配置 需要修改 cluster.name .node.name .network.host: 0.0.0.0[此处默认localhost].http.port: 9200 只要集群名相同,且机 ...
随机推荐
- 百度地图Label 样式 setStyle
最近一直在整百度地图,发现一个小问题: 创建文本标注对象设置样式的时候,其中的backgroundColor属性居然还支持透明啊,不过改变数值好像对效果没有影响 var numLabel = new ...
- 使用jmeter使用Jenkins发送自定义消息内容
Jenkins运行成功后,需要发送消息给用户,自己封装了一个rtx的方法,进行发送,配置方法如下: 1.在windows下选择 execute windows batch command,执行我的py ...
- Swift编程语言学习1.1——常量与变量
常量和变量把一个名字(比方maximumNumberOfLoginAttempts或者welcomeMessage)和一个指定类型的值(比方数字10或者字符串"Hello")关联起 ...
- JDK工具系列之jps
一.简介 jps(JVM Process Status Tool)是虚拟机进程状态工具:可以列出正在运行的虚拟机进程,显示虚拟机正在执行的main()函数,及这些进程的ID(LVMID,Local V ...
- thinkphp5.0查询到的数据表中的路径是反斜杠导致无法正常显示图片怎么办?
添加到数据表中图片的路径有时会是反斜杠,这就导致了在url后面写路径的时候会识别不出来(不过src后面写路径就可以识别),所以就需要把路径中的反斜杠替换成正斜杠,代码如下: $datu = Db::q ...
- Windows下我喜爱的那些体积小但功能强大的软件
我还是开门见山的说吧,接下来我给你大家介绍一些Windows上一些小软件,涉及到图片编辑,浏览器下载,文件搜索,音乐下载,文本编辑,视频录制等方面! 一:WinZIP中国 平常我们难免会遇到各种解压压 ...
- .ne 基础(2)
类是一种抽象 抽象的概念,具体的实例. 现实是先有对象,再抽象成类,再用类来创建实例 构造方法 (1)如果写好了类,不写构造方法,系统会默认一个无参的构造方法 (2) 如果手动添加了一个 构造方法,就 ...
- bootstrap table 解析写死的json.并且把进度条放进列中。
function showPhaseInfo(phase){ //json字符串转json对象 var phaseInfo = eval(phase); $('#phaseTable').bootst ...
- Web Mercator公开的小秘密
网上已经有好多作者都不吝笔墨,写了好多有关 Web Mercator这个坐标系的前世今生.多搜罗多摄入,我们会得到很多有用的信息.今天讨论到 3758,3857,102100,900913…… 这些I ...
- 使用ITextSharper小结
用到了生成PDF版的合同,上网研究了一圈,发现不需要服务器端安装插件的,比较好用的就是这个ITextSharper了,于是便开始了研究. 1.解决汉字不显示的问题,指定一下字体,默认的字体好像不支持中 ...