Latest posts by Cyrille Modiano (see all)
- Renaming a RAC cluster - 27/09/2018
- Stop/Start all RAC databases at once - 26/09/2018
- RMAN Backup script - 08/11/2017
This script can be used to show the top 10 SQL activity for the last hour.
It uses the v$active_session_history view to search top SQL by resource consumption.
Top 10 SQL Activity
SELECT trunc(sample_time,'MI'), sql_id, count(sql_id) as TOTAL FROM v$active_session_history WHERE sample_time between sysdate - interval '1' hour and sysdate AND sql_id in (select sql_id from ( select SQL_ID , sum(decode(session_state,'WAITING',1,1)) as TOTAL_ACTIVITY from v$active_session_history WHERE sample_time between sysdate - interval '1' hour and sysdate group by sql_id order by sum(decode(session_state,'WAITING',1,1)) desc) where rownum < 11) group by trunc(sample_time,'MI'),sql_id order by trunc(sample_time,'MI') desc
Here is the result you can obtain:
and the active sessions history graph for the same period:
Very good SQL statement, I’ll share it on my blog.
Thanks!
Thank you Vincent, you’re most welcome !
Are you putting the output in xls and generating the graph.
Hi,
I currently use SQL Server reporting services because I automated it but, you can do that with excel by using the HTML MARKUP.
Here is an exemple
Cyrille