Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there any way in PostgreSQL to know how much the cpu cost was per a query and/or by session. It doesn't have to be the exact system cpu usage more of a relative cost like we get with disk I/O. For Windows or Linux.

share|improve this question

The auto_explain module might be what you are looking for:

The statistics collector is probably the closest you can get to the Oracle v$ views:

Some more might be available in this extension:

share|improve this answer
That looks interesting, but I don't see it giving any CPU usage. Really something like v$mystat which Oracle has would be ideal. – GoatWalker Jan 23 '12 at 22:09
Sorry, I misread "cost" as "cost from the execution plan". See my edit for other options. – a_horse_with_no_name Jan 23 '12 at 22:16
The problem with all of those is they just give a general cost or in some cases the amount of io cost performed which is nice, but it's really nice to compare two solutions and see how much the io and the cpu are different at the sql statement, session, and transaction level. – GoatWalker Jan 23 '12 at 22:40
As you can reset the stats between running two statements you should at least be able to get the IO stats. – a_horse_with_no_name Jan 24 '12 at 10:32

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.