/********************************************
Author: Paresh Mehta
Script Name : waitt.sql
waits order by sql start time
********************************************/
set feedback 1
set pages 2000
set lines 230
column event format a45
column machin format a12
column modul format a10
column prg format a10
column osuser format a11
column username format a10
column sesinfo format a15
column blockedby format a15
alter session set nls_date_format='DDMONRR:HH24:MI:SS';
select /*+ first_rows(100) */ a.sid || ',' || a.serial# || ',@' || a.inst_id sesinfo,
a.username, a.osuser, a.sql_id, sql_exec_start,
substr(substr(a.machine,instr(machine, '\')+1),1,12) machin, substr(program,1,10) prg, substr(module, 1,10) modul, a.event,
blocking_session || '@' || blocking_instance blockedBy
from gv$session a
where status = 'ACTIVE'
and wait_class != 'Idle'
order by blocking_session desc, sql_exec_start desc
/