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 只要集群名相同,且机 ...
随机推荐
- Kafka与MQ的区别
作为消息队列来说,企业中选择mq的还是多数,因为像Rabbit,Rocket等mq中间件都属于很成熟的产品,性能一般但可靠性较强, 而kafka原本设计的初衷是日志统计分析,现在基于大数据的背景下也可 ...
- PHP5.5的新特性
看了@轩脉刃 今天出炉的PHP 5.5 新特性.不过没有翻译全,我这里稍微补充下,整理成完整的一篇:) 原文:http://www.php.net/manual/zh/migration55.new- ...
- PostgreSQL的generate_series函数应用
一.简介 PostgreSQL 中有一个很有用处的内置函数generate_series,可以按不同的规则产生一系列的填充数据. 二.语法 函数 参数类型 返回类型 描述 generate_serie ...
- D3——动态绑定数据
一.绑定数组元素 , , , , ]; d3.select("body") .selectAll("p") .data(dataset) .enter() .a ...
- bootstrap table footerFormatter用法 统计列求和 sum、average等
其实上一篇blog里已经贴了代码,简单解释一下吧: 1.showFooter: true,很重要,设置footer显示: $(cur_table).bootstrapTable({ url: '/et ...
- ojdbc14_g.jar与ojdbc14.jar区别
在低级JDK版本1.2与1.3中使用的驱动,class12.jar,虽然实际上在1.4,1.5中使用大部分情况也是OK的 ojdbc14.jar (1,545,954 bytes) - classes ...
- js获取昨天今天和明天
版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/UP19910522/article/details/30028299 <html> &l ...
- BZOJ2160:拉拉队排练(Manacher)
Description 艾利斯顿商学院篮球队要参加一年一度的市篮球比赛了.拉拉队是篮球比赛的一个看点,好的拉拉队往往能帮助球队增加士气,赢得最终的比赛.所以作为拉拉队队长的楚雨荨同学知道,帮助篮球队训 ...
- 【转】Android之drawable state各个属性详解
我们在定义一个drawable的时候可以通过xml定义的drawable对象.它使得一个图片能在不同的状态下显示不同的图案,比如一个Button,它有pressed,focused,或者其它状态,通过 ...
- Linux环境进程间通信: 共享内存
Linux环境进程间通信: 共享内存 第一部分 共享内存可以说是最有用的进程间通信方式,也是最快的IPC形式.两个不同进程A.B共享内存的意思是,同一块物理内存被映射到进程A.B各自的进程地址空间.进 ...