-- undo.sql: undo used by each open transaction, plus undo extent status -- Copyright (c) HASHJOIN. MIT License (https://hashjoin.com/kb/license/) -- https://hashjoin.com/kb/oracle/undo-usage-by-session/ -- -- Usage: @undo.sql -- -- curr_trx_kb assumes an 8 KB block size: change the 8 if yours differs. set feed on set trims on set lines 200 set pages 80 col sid_serial format a10 heading "S,SER" col user_stat format a13 trunc heading "User[sts]" col os_proc format a40 word wrap heading "Machine|[OSProc.OSUser@TERM]" col lockwait format a1 heading "L|W" col terminal format a8 col module format a50 trunc heading "Module" col segment_name format a13 heading "RBS-Name" col init_rbs_kb heading "RBS|Init KB" col curr_trx_kb heading "TRX|Curr KB" col trx_status format a12 heading "TRX-Status" col TABLESPACE_NAME format a9 break on report compute sum of curr_trx_kb on report select s.sid||','||s.serial# sid_serial , s.username||'['||substr(s.status,1,3)||']' user_stat --, s.machine||'['||s.process||'.'||s.osuser||'@'||s.terminal||']' os_proc --, s.lockwait , DECODE(s.program||' '|| s.module||' '|| s.action, ' ','MODULE DETAILS N/A' ,s.program||' '||s.module||' '||s.action) module , t.start_time --, r.segment_name , r.TABLESPACE_NAME --, (r.initial_extent*r.min_extents)/1024 init_rbs_kb , (t.used_ublk*8*1024)/1024 curr_trx_kb , decode(t.space, 'YES', 'SPACE TX', decode(t.recursive, 'YES', 'RECURSIVE TX', decode(t.noundo, 'YES', 'NO UNDO TX', t.status) )) trx_status from v$transaction t , dba_rollback_segs r , v$session s where t.xidusn = r.segment_id and t.ses_addr = s.saddr order by sid; select tablespace_name,STATUS,count(*),ceil(sum(bytes/1024/1024)) MB_SZ from dba_undo_extents group by tablespace_name,status order by 1; select ceil(sum(RSSIZE)/1024/1024) "UNDO Current Used Size (MB)" from v$rollstat a;