How to profile PostgreSQL Database?

本秂侑毒 提交于 2019-11-28 16:47:07

问题


I want to profile (keep an Eye on) all the activities that goes on in a Database which is in PostgreSQL.

Is there any such utility which will help me do this?


回答1:


For "keeping an eye", I use pgtop, a program which deliberately mimics Unix 'top' command.




回答2:


"Keep an eye on" and "profile" are two quite different tasks in my view.

For profiling (not a live view on what's going on right now, but to see which queries take most time etc), check out pgFouine:

http://pgfouine.projects.postgresql.org/

This will let you see which queries are resource intensive, and take appropriate action: Add missing indexes, rewrite queries using other techiques etc.




回答3:


Since rebra answer another profiling tool pgbadger went out. You can find it here: http://dalibo.github.io/pgbadger/

you can get a very detailed report and graphs.

pgfouine is not maintained anymore, last update was in 2010.




回答4:


Well, if you're looking at what's going on, regarding selects, updates, deletes, and so on, there are a few views in the pg_catalog schema, I mainly use pg_stat_user_tables and pg_stat_user_indexes but there are many more, all within pg_stat*.

There also is the pg_stat_activity view which tells you what's running on your server right now.

I've hacked together four munin plugins that uses the user_tables and user_indexes, they're available there




回答5:


Have a look at Nagios-Plugin script or check_postgres.pl



来源:https://stackoverflow.com/questions/365103/how-to-profile-postgresql-database

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!