Temp undo usage



Execute the following query to determine who is using a particular UNDO or Rollback Segment:
=============================================================================================
SELECT TO_CHAR(s.sid)||','||TO_CHAR(s.serial#) sid_serial,   
     NVL(s.username, 'None') orauser,   
     s.program,   
     r.name undoseg,   
     t.used_ublk * TO_NUMBER(x.value)/1024||'K' "Undo"   
FROM sys.v_$rollname    r,   
     sys.v_$session     s,   
     sys.v_$transaction t,   
     sys.v_$parameter   x 
WHERE s.taddr = t.addr 
    AND r.usn   = t.xidusn(+) 
   AND x.name  = 'db_block_size' 



Execute the following query to determine who is using a TEMP Segment:
=====================================================================
SELECT b.tablespace,   
     ROUND(((b.blocks*p.value)/1024/1024),2)||'M' "SIZE",   
     a.sid||','||a.serial# SID_SERIAL,   
     a.username,   
    a.program   
   FROM sys.v_$session a,   
        sys.v_$sort_usage b,   
        sys.v_$parameter p   
   WHERE p.name  = 'db_block_size' 
   AND a.saddr = b.session_addr 
   ORDER BY b.tablespace, b.blocks;



Check Temp Space

===============================================================spaces

SELECT s.username, s.sid, u.TABLESPACE, u.CONTENTS,
 sum(u.extents) extents, sum(u.blocks*8*1024)/1024/1024 MB
 FROM v$session s, v$sort_usage u
 WHERE s.saddr = u.session_addr
 GROUP BY s.username, s.sid, u.TABLESPACE, u.CONTENTS;




Instead use the V$TEMP_SPACE_HEADER view
=======================================
SELECT tablespace_name
, SUM(bytes_used)
, SUM(bytes_free) 
FROM   V$temp_space_header 
GROUP  BY tablespace_name;
 




To report true free space within the used portion of the TEMPFILE:
===================================================================
SELECT   A.tablespace_name tablespace, D.mb_total
         ,SUM (A.used_blocks * D.block_size) / 1024 / 1024 mb_used
         ,D.mb_total - SUM (A.used_blocks * D.block_size) / 1024 / 1024 mb_free 
FROM     v$sort_segment A,         
         (         
         SELECT   B.name
                  , C.block_size
                  , SUM (C.bytes) / 1024 / 1024 mb_total         
         FROM     v$tablespace B, v$tempfile C         
WHERE    B.ts#= C.ts#         
GROUP BY B.name, C.block_size         
         ) D 
WHERE    A.tablespace_name = D.name 
GROUP by A.tablespace_name, D.mb_total; 

Comments

Popular posts from this blog

Understanding Terraform

How to make CRS and ASM not to restart after server reboot

How to repair ASM disk header