How can I tell how many queries per second my Postgres database is executing?
- Anybody can ask a question
- Anybody can answer
- The best answers are voted up and rise to the top
migrated from stackoverflow.com Mar 5 '13 at 1:29
This question came from our site for professional and enthusiast programmers.
Use this query to read total number of transactions executed in all databases:
If you want the same counter for just one database, use:
To calculate TPS (transactions per second), run the query several times and calculate difference over time interval.
There are ready made tools for that, one of them is http://bucardo.org/wiki/Check_postgres
Update: Konrad corrected my misunderstanding of his question. The goal was to count queries, not transactions.
How to count queries?
Use pg_stat_statements contrib.
Enable full logging of queries for a representative period of time.
To enable full logging, for PostgreSQL 9.0 - 9.3, change following settings in
If you want to see also query duration, you can set
Then reload config (restart or HUP) and collect enough log to estimate traffic.
Note: neither method will include queries embedded in user-defined functions.