Home » RDBMS Server » Performance Tuning » Temp Tablespace running out of space (68 GB) (Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit)
Temp Tablespace running out of space (68 GB) [message #531747] Thu, 17 November 2011 08:44 Go to next message
manubatham20
Messages: 566
Registered: September 2010
Location: Seattle, WA, USA
Senior Member

Hi,

I am getting temp tablespace error "ORA-01652: unable to extend temp segment by 128 in tablespace TEMP" for the following code.

SELECT /*+ USE_NL ( vd1 ,vd2 ,vd3  ) leading ( vd1 ,vd2 ,vd3  , tvd) */ vd1.vendor_record_seq_no,
tvr.checksum, tvr.rownumber, tvr.transaction_type, 'U'  
  FROM vendor_data vd1, vendor_data vd2, vendor_data vd3,
  (SELECT  rownumber, MAX (DECODE (control_column_seq_no, 91150, original_value, NULL)) AS value1,
  MAX (DECODE (control_column_seq_no, 91152, original_value, NULL)) AS value2,
  MAX (DECODE (control_column_seq_no, 91141, original_value, NULL)) AS value3
  	  FROM (SELECT /*+ dynamic_sampling(vdt 3) dymanic_sampling_est_cdn(vdt) */ rownumber, 
   		   	VALUE AS original_value,control_column_seq_no
				  FROM temp_vendor_data vdt
				  WHERE vdt.KEY = 'Y' AND error_flag IS NULL) temp 
  GROUP BY rownumber) tvd, temp_vendor_record tvr 
  WHERE vd1.study_seq_no = 25706 AND vd1.control_column_seq_no = 91150


Right now used tables has the following number of records-

SELECT COUNT(*) FROM vendor_data --292890442
SELECT COUNT(*) FROM temp_vendor_data --0
SELECT COUNT(*) FROM temp_vendor_record --0

This query is part of an application, but consuming too much of temporary tablespace (68 GB allocated). I found it out by using query below:

select * from v$session a, v$sql b
   where a.sql_id=b.sql_id
   and status = 'ACTIVE'


I am not sure, why this problem is occuring. Please help, what other information I should provide.

Thanks,
Manu.
Re: Temp Tablespace running out of space (68 GB) [message #531748 is a reply to message #531747] Thu, 17 November 2011 08:44 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
01652, 00000, "unable to extend temp segment by %s in tablespace %s"
// *Cause:  Failed to allocate an extent of the required number of blocks for
//          a temporary segment in the tablespace indicated.
// *Action: Use ALTER TABLESPACE ADD DATAFILE statement to add one or more
//          files to the tablespace indicated.
Re: Temp Tablespace running out of space (68 GB) [message #531752 is a reply to message #531748] Thu, 17 November 2011 08:47 Go to previous messageGo to next message
manubatham20
Messages: 566
Registered: September 2010
Location: Seattle, WA, USA
Senior Member

Are you sure extending tablespace will certainly resolve my issue? I have already get it extended up to 68 GB. How can I estimate required tempspace.

Is there any other work-around?

Thanks,
Manu
Re: Temp Tablespace running out of space (68 GB) [message #531754 is a reply to message #531752] Thu, 17 November 2011 08:49 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
>Are you sure extending tablespace will certainly resolve my issue?
yes

>I have already get it extended up to 68 GB.
>How can I estimate required tempspace.
use a larger value.

>Is there any other work-around?
none that I know about
Re: Temp Tablespace running out of space (68 GB) [message #531763 is a reply to message #531747] Thu, 17 November 2011 09:29 Go to previous messageGo to next message
flyboy
Messages: 1903
Registered: November 2006
Senior Member
Maybe this:
FROM ..., vendor_data vd2, vendor_data vd3
The query contains two references to VENDOR_DATA table without using any column from them in SELECT clause nor join conditions. This leads to cartesian product (CROSS JOIN), so for each output row of the query rest, extra 292890442*292890442 rows. Although, if other tables had zero rows (are you sure it is correct during query run? - data in global temporary tables may not be visible to other sessions), the result set would contain zero rows. Are statistics on all tables current? Are all tables normal heap tables or are some of them global temporary ones?
Also other tables are not joined, so the same multiplication of rows will happen.

Of course, the best workaround would be fixing this query to properly join tables - add correct join conditions and/or remove the unused tables.
Re: Temp Tablespace running out of space (68 GB) [message #532533 is a reply to message #531763] Wed, 23 November 2011 04:41 Go to previous message
dee_bee_eh
Messages: 6
Registered: November 2011
Junior Member
explain plan will give you the estimated temporary space for any query that needs it, ie, the PGA isnt sufficient

then explain plan for <your SQL>
and then select * from table(dbms_xplan.display);

run the plan table utl package for the latest plan table

you should get the following (tempspc is missing if the pga is enough for the query)
Id | Operation | Name | Rows | Bytes |TempSpc| Cost

you should also see the cartesian in the plan.




[Updated on: Wed, 23 November 2011 04:42]

Report message to a moderator

Previous Topic: At the end of the road of my sql tuning
Next Topic: Elapsed Time in Trace file output (2 Merged)
Goto Forum:
  


Current Time: Thu Nov 28 05:20:53 CST 2024