Take the 2-minute tour ×
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. It's 100% free, no registration required.

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
add comment

1 Answer

The auto_explain module might be what you are looking for:

http://www.postgresql.org/docs/current/static/auto-explain.html

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

http://www.postgresql.org/docs/current/static/monitoring-stats.html#MONITORING-STATS-VIEWS

Some more might be available in this extension:

http://www.postgresql.org/docs/current/static/pgstatstatements.html

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. –  Bob 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. –  Bob 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
add comment

Your Answer

 
discard

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.