标题: Temporary Segments In Permanent Tablespaces Aren't Cleaned For A Long Time [打印本页] 作者: 郑全 时间: 2021-8-10 22:40 标题: Temporary Segments In Permanent Tablespaces Aren't Cleaned For A Long Time Temporary Segments In Permanent Tablespaces Aren't Cleaned For A Long Time (Doc ID 1271120.1) To BottomTo Bottom
APPLIES TO:
Oracle Database Exadata Express Cloud Service - Version N/A and later
Oracle Database Exadata Cloud Machine - Version N/A and later
Oracle Database Cloud Exadata Service - Version N/A and later
Oracle Database Backup Service - Version N/A and later
Oracle Cloud Infrastructure - Database Service - Version N/A and later
Information in this document applies to any platform.
SYMPTOMS
Querying DBA_Segments shows a number of temporary segments in permanent tablespaces that aren't being cleaned up for a long time.
Checking if SMON is disabled for cleanup of temporary segments:
SQL> show parameter events
-- If event 10061 is set at level 10, it implies that cleanup of temp segments by SMON is disabled
-- and 1st a check needs to be done if after disabling the event the segments are cleaned up:
SQL> alter system set events '10061 trace name context off';
Forcing SMON to clean up the temporary segments in the tablespace like below does not work:
SQL> ALTER TABLESPACE TBS_1 coalesce;
Bouncing the database does not clean up these segments.
CAUSE
This might be caused by having the permanent tablespaces in read-only mode before the temporary segments were cleaned up.
This causes SMON to not be able to clean them afterwards even when forcing it to using 'alter tablespace ... coalesce'.
Querying DBA_tablespaces shows that the tablespaces are in read-only mode.
SQL> Select tablespace_name, status from dba_tablespaces;
TABLESPACE_NAME STATUS
------------------------------ ---------
TBS_1 READ ONLY
TBS_2 READ ONLY
SOLUTION
Change the tablespace to read-write mode. Then force SMON to clean-up the temporary segments. If needed put the tablespace back in read-only mode.
1. Put one of the table spaces in read-write mode.
SQL> alter tablespace TBS_1 read write;
2. Force SMON to clean up the temporary segments.
SQL> alter tablespace TBS_1 coalesce;
3. Put the table space back in read-only mode.
SQL> alter tablespace TBS_1 read only;
REFERENCES
NOTE:102339.1 - Temporary Segments: What Happens When a Sort Occurs
NOTE:106717.1 - How To Determine The Cause Of a Large TEMPORARY Segment In PERMANENT Tablespace
NOTE:177334.1 - Overview of Temporary Segments