Wednesday, March 15, 2006

Who eats my Temp Space

Many a times we get the error : "TEMP SEGMENT MAXIMUM EXTENT EXCEEDED". The following script will provide a list of users and which processes occupy space in the TEMP tablespace.

SET pagesize 10000;
SET linesize 133;
column tablespace format a15 heading 'Tablespace Name';
column segfile# format 9,999 heading 'File|ID';
column spid format 9,999 heading 'Unix|ID';
column segblk# format 999,999,999 heading 'Block|ID';
column size_mb format 999,999,990.00 heading "Mbytes|Used";
column username format a15;
column program format a15;
SELECT
b.tablespace,
b.segfile#,
b.segblk#,
round(((b.blocks*p.value)/1024/1024),2 ) size_mb ,
a.sid,
a.serial#,
a.username,
a.osuser,
a.program,
a.status
FROM v$session a ,
v$sort_usage b ,
v$process c ,
v$parameter p
WHERE p.name='db_block_size'
AND a.saddr = b.session_addr
AND a.paddr=c.addr
ORDER BY b.tablespace,
b.segfile#,
b.segblk#,
b.blocks
/

No comments: