persistent error - unable to extend temp segment by 128 in tablespace TEMP - oracle

I was given a query that's running out of space in the TEMP tablespace. (see error-message below) As a quick solution to get the user back up and running, I simply added a TEMPFILE to the tablespace. (see alter statement below) But, when I ran the query again, it still ran out of space. I can see from querying dba_temp_files that the tablespace is pretty big, and it does contain both datafiles, but I thought the MAXSIZE UNLIMITED clause would have solved my problem by not allowing the new datafile to run out of space.
Besides rewriting the query, what would you recommend?
Thanks!
Dave
SQL Error: ORA-01652: unable to extend temp segment by 128 in tablespace TEMP
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.
ALTER TABLESPACE temp
ADD TEMPFILE '+DATAC1/cop3/tempfile/temp01.dbf' SIZE 10g
AUTOEXTEND ON
NEXT 1g
MAXSIZE UNLIMITED;
SQL> SELECT substr(tablespace_name,1,4) as tbls,
2 substr(file_name,1,40) as file_name,
3 bytes/1000000000 as gigabytes
4 FROM dba_temp_files
5 WHERE tablespace_name = 'TEMP'
6 ;
TBLS FILE_NAME GIGABYTES
---- ---------------------------------------- ----------
TEMP +DATAC1/cop3/tempfile/temp.771.915115045 21.4748365
TEMP +DATAC1/cop3/tempfile/temp01.dbf 34.359722

Related

How to find TEMP tablespace usage?

we are using v$sort_segment to calculate temp file usage. but one of my temp tablespace not available in v$sort_segment table. IS there any other way to get the correct usage which returns the same value as in v$sort_segment?
V$SORT_SEGMENT only gets populated as a temporary segment is required. For example, if I create a second temp tablespace, then it does not appear because it is not in use
SQL> create temporary tablespace temp2 tempfile 'X:\ORACLE\ORADATA\DB19\PDB1\TEMP02.DBF' size 20m;
Tablespace created.
SQL> select tablespace_name from v$sort_segment;
TABLESPACE_NAME
------------------------
TEMP
If you want a view of all of your temporary tablespaces, you can outer join either DBA_TABLESPACES (type=TEMPORARY) or DBA_TEMP_FILES to V$SORT_SEGMENT.

unable to extend temp segment by 128 in tablespace TEMP for clob

I am working on a project in which I am working on database where in java program I need to read the clob data from datafile and then creating clob object and setting clob data in the object and insert row. I am doing batch insert with 10000 rows. But after reading some (32) rows, I am getting following error:-
java.io.IOException: ORA-01652: unable to extend temp segment by 128 in tablespace TEMP
at oracle.jdbc.driver.OracleClobOutputStream.flushBuffer(OracleClobOutputStream.java:293)
at oracle.jdbc.driver.OracleClobOutputStream.write(OracleClobOutputStream.java:191)
at org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:1793)
at org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:1769)
at org.apache.commons.io.IOUtils.copy(IOUtils.java:1744)
I searched this error online and found some solutions on site. I have executed the following queries then:-
select value from v$parameter where name = 'db_block_size';
select bytes/1024/1024 as mb_size,
maxbytes/1024/1024 as maxsize_set, x.*
from dba_data_files x;
alter tablespace system add datafile 'C:\APP\ADMIN\ORADATA\VIDUSHIEXTRACT\DATAFILE\O2_MF_USERS_FLHMH039_.DBF' size 5024m autoextend on maxsize unlimited;
FYI: In my db the above type of data files are multiple.
But after all this also I got the same error after 32 rows(I have 1028 rows total in my table, in which each clob column data has approx 4MB data). So please can anyone tell me what should I do now, in order to resolve this issue?
you extended the SYSTEM tablespace by adding a datafile, but you need to extent the TEMP tablespace (as suggested by the error)

ORA-01652: unable to extend temp segment by 128 in tablespace TEMP - is this recoverable?

I have a table that has 188307430 records.
It also has partitions.
above two statements I realized after firing a SELECT on the table
select * from emp order by created_date;
This caused the above exception related to temp segment in TEMP tablespace.
So I have multiple questions:
Is this issue recoverable - i.e will all other users get impacted ?
or will other selects simply cause Oracle to cleanup the TEMP tablespace ?
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.
Yes this recoverable. In Oracle database SMON process is responsible to clean temp segments that are no longer needed.
will all other users get impacted ?
Yes, If their SQLs need TEMP segments then they are also impacted.

ORA-01658: unable to create INITIAL extent for segment in tablespace TS_DATA

When i tried to create a table in my User_DB schema i am getting an error as ORA-01658: unable to create INITIAL extent for segment in tablespace TS_DATA. I run the following query to get all the TABLESPACE_NAME:
SELECT * FROM DBA_DATA_FILES;
But i really dont know which tablespace i am using and how to extend the tablespace to solve this issue.
As the error message indicates, you're using the TS_DATA tablespace. You can extend it by either enlarging one of the existing data files:
ALTER DATABASE
DATAFILE 'C:\ORACLEXE\APP\ORACLE\ORADATA\XE\TS_DATA.DBF'
RESIZE 3000M;
Or by adding a second datafile to the tablespace:
ALTER TABLESPACE ts_data
ADD DATAFILE 'C:\ORACLEXE\APP\ORACLE\ORADATA\XE\TS_DATA2.DBF'
SIZE 1000M;
Or just allow the datafile to auto extend:
ALTER DATABASE
DATAFILE 'C:\ORACLEXE\APP\ORACLE\ORADATA\XE\TS_DATA2.DBF'
AUTOEXTEND ON
MAXSIZE UNLIMITED; -- Or some reasonable cap
To check existing table spaces data file and size by following sql
select a.file_id,b.file_name,b.autoextensible,b.bytes/1024/1024,sum(a.bytes)/1024/1024
from dba_extents a , dba_data_files b
where a.file_id=b.file_id
group by a.file_id,b.file_name,autoextensible,b.bytes/1024/1024
Then run following sql, it would to make auto extend data file size.
ALTER DATABASE
DATAFILE '/u01/app/oracle/oradata/XE/TS_DATA.dbf'
AUTOEXTEND ON
MAXSIZE UNLIMITED;

ORA-01652 - Query doen't work with hibernate but it works fine in SQL client

I execute a SQL query with hibernate and the application give the error:
ORA-01652: unable to extend temp segment
The TABLE SPACE has 4 GB.
The strange thing is that the query from the application yesterday was working fine, and today it doen't work.
I have not made any changes either in the database or application.
The oracle version is Oracle 11g
You are running short on space in temp tablespace , use this query t check how much space you have in your temp tablespace
SQL> select file_name,SUM(bytes)/1024/1024 "Current_size_mb", sum(maxbytes)/1024/1024 "max_size_mb" from dba_temp_files group by file_name;
FILE_NAME Current_size_mb max_size_mb
---------------------------------------------------------------------- --------------- -----------
C:\AKS\AKDB\ORADATA\RESEARCH\TEMP01.DBF 20 32767.9844
Adding a new tempfile to temp tablespace
SQL> alter tablespace temp add tempfile 'C:\AKS\AKDB\ORADATA\RESEARCH\TEMP02.DBF' size 100m autoextend on maxsize 1g;
Temporary tablespace called TEMP which is used internally by database for operations like distinct, joins,etc to fetch large amount of data.
So, after increasing the size of TEMP tablespace the issue can be resolved.
Follow this link : How to shrink temp tablespace in oracle?

Resources