-- t10s.sql: top 10 active sessions by logical and physical I/O -- Copyright (c) HASHJOIN. MIT License (https://hashjoin.com/kb/license/) -- https://hashjoin.com/kb/oracle/top-sessions-by-io/ -- -- Usage: @t10s.sql -- @t10s.sql 10 only sessions active for more than 10 minutes alter session set nls_date_format='RRRR-DD-MON HH24:MI'; set lines 256 set trims on col sid_serial format a12 heading "Sid,Serial" col USERNAME format a8 trunc heading "User" col MACHINE format a10 trunc heading "Machine" col PROCESS format a10 heading "PROCESS" col spid format a10 heading "SPID" col OSUSER format a10 trunc heading "OS-User" col logon format a15 heading "Login Time" col idle format a8 heading "Idle" col status format a1 heading "STS" col lockwait format a1 heading "L|W" col module format a35 trunc heading "Module" select top_ten.tot_value , chr(39)||s.sid||','||s.serial#||chr(39) sid_serial , s.username , SUBSTR(s.status,1,1) status , s.lockwait , s.osuser , s.process , p.spid , s.machine , to_char(s.logon_time,'DDth HH24:MI:SS') logon , floor(last_call_et/60) ACTIVE_MIN , s.program||' '||s.module||' '||s.action module from (select tot_value , sid from (select sum(stat.value) tot_value , s.sid from v$sesstat stat , v$statname sname , v$session s where s.sid = stat.sid and stat.STATISTIC# = sname.STATISTIC# and sname.name IN( 'consistent gets', 'db block gets' , 'physical reads' , 'db block changes') and s.type <> 'BACKGROUND' and s.schemaname <> 'SYS' and s.status = 'ACTIVE' group by s.sid order by tot_value desc) where rownum < 11) top_ten , v$session s , v$process p where top_ten.sid = s.sid and floor(last_call_et/60) > &&1 and s.paddr = p.addr order by 1 desc; undefine 1