This article is half-done without your Comment! *** Please share your thoughts via Comment ***
This is the second day with the PostgreSQL pg_stat_statements module.
In the previous post, I have shared basic steps to configure and enable pg_stat_statements module for tracking query statistics.
In this post, I have prepared one small DBA script to find query statistics such a way that we can easily see the long executed queries.
The PostgreSQL database administrator can use this script for investigating performance related issues.
1 2 3 4 5 6 7 8 9 10 11 |
SELECT pd.datname ,pss.query AS SQLQuery ,pss.rows AS TotalRowCount ,(pss.total_time / 1000 / 60) AS TotalMinute ,((pss.total_time / 1000 / 60)/calls) as TotalAverageTime FROM pg_stat_statements AS pss INNER JOIN pg_database AS pd ON pss.dbid=pd.oid ORDER BY 1 DESC LIMIT 10; |