In this Document
APPLIES TO:Oracle Database - Enterprise Edition - Version 8.0.6.0 to 11.2.0.2.0 [Release 8.0.6 to 11.2]Information in this document applies to any platform. ***Checked for relevance on 21-Jul-2017*** SYMPTOMSOracle database instances will from time to time experience CAUSEEXAMPLE 1: SOLUTIONFirst it is important to forget what is known about past behavior of the instance as the current tablespace size is insufficient to handle the demand by current sessions |
In this Document
APPLIES TO:Oracle Database - Enterprise Edition - Version 8.1.7.0 and laterInformation in this document applies to any platform. ***Checked for relevance on 21-Jul-2017*** GOALSuggest a method by which temporary segment usage be monitored over time SOLUTIONCASE STUDY: EXAMPLE of how to monitor Temporary Segment Usage over time
-- NOTE: If SYS is unacceptable then use a schema that has access of each of the DBA views below -- Create a table to hold your temporary space monitoring
CREATE TABLE TEMP_TEMP_SEG_USAGE(
DATE_TIME DATE, USERNAME VARCHAR2(30), SID VARCHAR2(6), SERIAL# VARCHAR2(6), OS_USER VARCHAR2(30), SPACE_USED NUMBER, SQL_TEXT VARCHAR2(1000));
CREATE OR REPLACE PROCEDURE TEMP_TEMP_SEG_USAGE_INSERT IS
BEGIN insert into TEMP_TEMP_SEG_USAGE SELECT sysdate,a.username, a.sid, a.serial#, a.osuser, b.blocks, c.sql_text FROM v$session a, v$sort_usage b, v$sqlarea c WHERE b.tablespace = 'TEMP' and a.saddr = b.session_addr AND c.address= a.sql_address AND c.hash_value = a.sql_hash_value AND b.blocks*(select block_size from dba_tablespaces where tablespace_name = b.tablespace) > 1024; COMMIT; END; / SELECT JOB FROM DBA_JOBS; JOB ---------- 19 BEGIN DBMS_JOB.ISUBMIT(JOB => 20, WHAT => 'TEMP_TEMP_SEG_USAGE_INSERT;', NEXT_DATE => SYSDATE, INTERVAL => 'SYSDATE + (5/1440)'); COMMIT; END; /
CREATE OR REPLACE PROCEDURE TEMP_TEMP_SEG_USAGE_INSERT IS
BEGIN insert into TEMP_TEMP_SEG_USAGE SELECT sysdate,a.username, a.sid, a.serial#, a.osuser, b.blocks, c.sql_text FROM v$session a, v$sort_usage b, v$sqlarea c WHERE b.tablespace = 'TEMP' and a.saddr = b.session_addr AND c.address= a.sql_address AND c.hash_value = a.sql_hash_value AND b.blocks*(select block_size from dba_tablespaces where tablespace_name = b.tablespace) > 1024; COMMIT; END; / SELECT JOB FROM DBA_JOBS; JOB ---------- 19 BEGIN DBMS_JOB.ISUBMIT(JOB => 20, WHAT => 'TEMP_TEMP_SEG_USAGE_INSERT;', NEXT_DATE => SYSDATE, INTERVAL => 'SYSDATE + (5/1440)'); COMMIT; END; /
select segment_name, tablespace_name, bytes/ (1024*1024) UsedMb truncate table <temporary tablespace name to monitor>_TEMP_SEG_USAGE;
select * from temp_temp_seg_usage;
DATE_TIME USERNAME SID SERIAL --------- --------------------- ----- ---- OS_USER SPACE_USED ------------------------------ ---------- SQL_TEXT ----------------------------------------- 29-JUN-07 SYS 158 13 sygaw-ca\sygaw 768 select * from dba_objects order by object_id, object_name select segment_name, tablespace_name, bytes/ (1024*1024) UsedMb from dba_segments where segment_name='TEMP_TEMP_SEG_USAGE'; SEGMENT_NAME ------------------------------------------ TABLESPACE_NAME USEDMB ------------------------------ ---------- TEMP_TEMP_SEG_USAGE SYSTEM .0625 truncate table temp_temp_seg_usage; Table truncated. |
select max(bytes)/1024/1024 from dba_free_space
where tablespace_name = 'TBS_BIEETL_DATA';
SQL> select count(*) from dba_recyclebin;
COUNT(*)
----------
1875
SQL> select max(bytes)/1024/1024 from dba_free_space
2 where tablespace_name = 'TBS_BIEETL_DATA';
MAX(BYTES)/1024/1024
--------------------
3968
select tablespace_name, file_id, bytes_used, bytes_free
from v$temp_space_header ;
alter system set events '1658 trace name errorstack level 3';
alter system set events '1653 trace name errorstack level 3';
alter system set events '1652 trace name errorstack level 3';