Logo

SQL Script

TOP CPU

Tested on Oracle 8.1

Updated : 08-Jan-2002
Version : 1.0

Description

Script displays details so the session which have used the most CPU. Needs the Init.Ora parameter timed_statistics set to true to work.

Parameters

None

SQL Source

col program form a30 heading "Program"
col CPUMins form 99990 heading "CPU Mins"

spool topcpu.lst

select rownum as rank, a.*
from (
    SELECT v.sid, program, v.value / (100 * 60) CPUMins
    FROM v$statname s , v$sesstat v, v$session sess
   WHERE s.name = 'CPU used by this session'
     and sess.sid = v.sid
     and v.statistic#=s.statistic#
     and v.value>0
   ORDER BY v.value DESC) a
where rownum < 11
   ;

spool off

Return to Index of SQL Scripts


Home | Company Profile | Services | Contact Us | SQL scripts and tips | Quiz
Legal

Logo