Home » SQL & PL/SQL » SQL & PL/SQL » Struggling with Query holding temp space (Oracle Database 11g Enterprise Edition Release 11.2.0.4.0)
Struggling with Query holding temp space [message #642029] Mon, 31 August 2015 10:21 Go to next message
manubatham20
Messages: 566
Registered: September 2010
Location: Seattle, WA, USA
Senior Member

Hello,

I am struggling to find the query sessions which are holding temp space.
The tempspace (temporary tablespace) is slightly increasing, and I am not able to trace which queries causing increase in occupied temp space.

  SELECT MACHINE,
         hash_value,
         sql_text,
         COUNT (*) cnt,
         SUM (mb_used) mb_used
    FROM (  SELECT S.sid || ',' || S.serial# sid_serial,
                   S.username,
                   s.machine,
                   T.blocks * TBS.block_size / 1024 / 1024 mb_used,
                   T.tablespace,
                   T.sqladdr address,
                   Q.hash_value,
                   Q.sql_text
              FROM v$sort_usage T,
                   v$session S,
                   v$sqlarea Q,
                   dba_tablespaces TBS
             WHERE     T.session_addr = S.saddr
                   AND T.sqladdr = Q.address(+)
                   AND T.tablespace = TBS.tablespace_name
          ORDER BY S.sid)
GROUP BY machine, hash_value, sql_text
ORDER BY 5 DESC, 4 DESC;


I have used above query to find queries holding tempspace, I am not sure if this is the correct way.

Thanks,
Manu
Re: Struggling with Query holding temp space [message #642030 is a reply to message #642029] Mon, 31 August 2015 10:30 Go to previous message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
https://www.google.com/webhp?hl=en&tab=ww#hl=en&q=oracle+session+using+temporary+tablespace
Previous Topic: MERGE
Next Topic: Order by in Listagg
Goto Forum:
  


Current Time: Thu Apr 18 03:36:10 CDT 2024