Active Session History Longest SQL

SELECT STAT.INSTANCE_NUMBER, STAT.SQL_ID, SQL_TEXT, PLAN_HASH_VALUE, PARSING_SCHEMA_NAME, ELAPSED_TIME_DELTA/1000000 SECONDS, round((ELAPSED_TIME_DELTA/1000000)/60,2) MINUTES, (ELAPSED_TIME_DELTA/1000000) / EXECUTIONS_DELTA, round((ELAPSED_TIME_DELTA/1000000)/60 / EXECUTIONS_DELTA,2) “TIME PER EXEC”, STAT.SNAP_ID, SS.END_INTERVAL_TIME, EXECUTIONS_DELTA FROM DBA_HIST_SQLSTAT STAT, DBA_HIST_SQLTEXT TXT, DBA_HIST_SNAPSHOT SS WHERE STAT.SQL_ID = TXT.SQL_ID AND STAT.DBID = TXT.DBID AND SS.DBID = STAT.DBID AND SS.INSTANCE_NUMBER = STAT.INSTANCE_NUMBER AND STAT.SNAP_ID = SS.SNAP_ID AND PARSING_SCHEMA_NAME = ‘SCOTT’ AND SS.BEGIN_INTERVAL_TIME … Read more

Average Active Sessions

How to find the average active sessions between 2 dates. SELECT rollup_timestamp, average, minimum, maximum FROM mgmt$metric_daily WHERE target_name = ‘TRCOPDOV’ AND metric_label = ‘Throughput’ AND column_label = ‘Average Active Sessions’ AND rollup_timestamp BETWEEN TO_DATE (’01/11/2015′, ‘dd/mm/yyyy’) AND TO_DATE (’01/12/2015′, ‘dd/mm/yyyy’) ORDER BY 1;