35

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?

5 Answers 5

37

"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.

Sign up to request clarification or add additional context in comments.

1 Comment

Link is dead. Read @l-g answer: pgbadger as substitute.
21

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

3 Comments

To save someone a minute or two: I found this only under the package name ptop in Debian, though the command itself is called pg_top.
link is not available anymore?
@GunnlaugurBriem Since version 4 it has been renamed to pgtop.
13

PgBadger is an actively maintained profiling tool that provides very detailed reports and graphs (see examples). It can process large volumes of PostgreSQL logs to answer questions like:

  • The most frequent waiting queries.
  • Queries that waited the most.
  • The slowest queries.

(PgBadger was explicitly built to "replace and outperform" pgFouine, which has not been maintained since about 2010.)

Comments

6

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

3 Comments

mat, do you still have the plugins available somewhere? The link points to 404 not found
Hum, unless I'm mistaken, munin comes with a dozen plugins for postgresql that do exactly what mine did. If I'm mistaken, tell me, I'll try to find out what happened with the ones I crafted.
Munin project here
2

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.