Quantcast
Channel: Doyensys Allappsdba Blog..
Viewing all articles
Browse latest Browse all 1640

Query to find out the sql which used high CPU.

$
0
0
Please use the below.

set lines 500;
set pages 500;
set long 1000000;
SELECT X.SQL_ID, X.CPU_TIME, X.EXECUTIONS, T.SQL_TEXT
FROM
   DBA_HIST_SQLTEXT T,
   (
      SELECT
         S.SQL_ID SQL_ID,
         SUM(S.CPU_TIME_DELTA/1000000) CPU_TIME,
         SUM(S.EXECUTIONS_DELTA) EXECUTIONS
      FROM
         DBA_HIST_SQLSTAT S,
         DBA_HIST_SNAPSHOT P
      WHERE
         S.SNAP_ID = P.SNAP_ID AND
         P.BEGIN_INTERVAL_TIME >= TO_DATE('&beginTime', 'MM/DD/YYYY HH24:MI') AND
         P.END_INTERVAL_TIME <= TO_DATE('&endTime', 'MM/DD/YYYY HH24:MI')
      GROUP BY S.SQL_ID
   ) X
WHERE T.SQL_ID = X.SQL_ID
ORDER BY X.CPU_TIME DESC;

Viewing all articles
Browse latest Browse all 1640

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>