对于性能分析,最基本得是DB运行信息的收集,oracle里提供statspack,9i开始叫AWR报告,在Postgresql下也有这样的一个工具。基本具备了oracle类似的功能:
9.0的使用手册:http://www.postgresql.org/docs/9.0/interactive/pgstatstatements.html
pgstatpack下载地址:http://pgfoundry.org/projects/pgstatspack
使用心得:http://blogold.chinaunix.net/u2/84422/showart_2342422.html
-- 部署
pgstatpack需要使用psql的 pg_stat_statement模块,因此安装部署分为 pg_stat_statement和pgstatpack2个工具的部署
1.部署 pg_stat_statement moudle
1.1部署lib库,或者直接从/contrib/pg_stat_statement make&&make install
cp pg_stat_statements.so /usr/lib64/pgsql/
chmod 755 /usr/lib64/pgsql/pg_stat_statements.so
1.2运行 pg_stat_statement.sql
文档:
http://www.postgresql.org/docs/9.0/interactive/pgstatstatements.html
su - postgres
psql -f pg_stat_statements.sql hm_temp
psql -f pg_stat_statements.sql hm
1.3修改参数 shared_preload_libraries
shared_preload_libraries = 'pg_stat_statements'
然后再重新启数据库
2.部署pgstatspack
下载:
http://pgfoundry.org/frs/?group_id=1000375&release_id=1701
tar -xzvf pgstatspack_version_2.2.tar.gz
cd pgstatspack
./install_pgstats.sh
--crontab
#Create a cron job for the postgres OS user I suggest every 15 minutes
*/15 * * * * /home/xwzhou/install_files/pg_stat/pgstatspack/bin/snapshot.sh 1> /home/xwzhou/install_files/pg_stat/pgstatspack/snape_file 2>&1
#purge old snapshots I suggest keeping about 30 days this will run at 0302 2 3 * * * /home/xwzhou/install_files/pg_stat/pgstatspack/bin/delete_snapshot.sh 1> /home/xwzhou/install_files/pg_stat/pgstatspack/delete_file 2>&1
原文链接:https://www.f2er.com/postgresql/196527.html