Skip to content
pvmehta.com

pvmehta.com

  • Home
  • About Me
  • Toggle search form
  • To see how much time or progress of long transaction Oracle
  • Is It Recommended To Apply Patch Bundles When PSU Is Available? -ID 743554.1 Oracle
  • My Minimum Tuning Programs Oracle
  • How does one SELECT a value from a table into a Unix variable? From SQL to Shell Linux/Unix
  • find_pk.sql /* Find Primary Key */ Oracle
  • Alter procedure auditing Oracle
  • rm_backup_arch_file.ksh Linux/Unix
  • How to collect CPU usage on Linux using Shell script Linux/Unix
  • Explain Plan Doesn’T Change For Sql After New Statistics Generated Oracle
  • How to find the real execution plan and binds used in that explain plan in Oracle 10g?? Oracle
  • Reading parameter file and printing Linux/Unix
  • How to hide author name in WordPress BLOG PHP/MYSQL/Wordpress
  • My Test Case On 21-OCT-2005 Oracle
  • Index Range Scan Oracle
  • Another Tuning Article for subheap of shared pool Oracle

Temporary Tablespsace Temp tablespace behaviour

Posted on 25-May-2010 By Admin No Comments on Temporary Tablespsace Temp tablespace behaviour

Description

===========

When monitoring the size of the available free space in the TEMPORARY tablespace

it does not increased once sorts are finished even with no client connections

to the database. They may also be a large number of EXTENTS of type TEMPORARY

in the temporary tablespace.

Users may also experience ORA-1652 when running transactions. This error implies

that there is no free space left. SMON is not cleaning up after waiting for

hours and queries are failing.

Scope & Application

===================

If the TEMPORARY TABLESPACE is of type TEMPORARY, the space is not released

until the instance is shutdown. If the TEMPORARY TABLESPACE is of type

PERMANENT, then cleanup is performed by SMON after completion of the process

using it.

A sort segment is created by the first statement that uses a TEMPORARY

tablespace for sorting, after startup. These are not released until the

database is restarted. The view V$SORT_SEGMENT can be used to see how

many of the currently allocated sort segments are being used.

If a PERMANENT tablespace is used for sorting, then any temporary segments

created are dropped by SMON on completion of the statement, and the space

is released for use by other objects.

Running the query:

select OWNER,

SEGMENT_NAME,

SEGMENT_TYPE ,

TABLESPACE_NAME

from DBA_SEGMENTS

where SEGMENT_TYPE = ‘TEMPORARY’;

to give results similar to:

OWNER SEGMENT_NAME SEGMENT_TYPE TABLESPACE_NAME

—– ———— ———— —————

SYS 4.2 TEMPORARY TEMP

Note: segment_name and tablepace_name are likely to be different.

Then determine the tablespace type by running:

select TABLESPACE_NAME,

CONTENTS

from DBA_TABLESPACES

where TABLESPACE_NAME in ();

to give results similar to:

TABLESPACE_NAME CONTENTS

—————————— ———

TEMP TEMPORARY

TEMP1 PERMANENT

The above query will indicate what type of tablespace the database has defined.

Explanation

===========

If the tablespace in which the TEMPORARY segment resides is of type

TEMPORARY then sort segments not being released is normal behavior in 7.3+.

ORA-1652 implies that the tablespace is too small.

A sort segment is created by the first statement that used a TEMPORARY tablespace

for sorting, after startup. A sort segment created in a TEMPOARY tablespace

is only released at shutdown. The large number of EXTENTS is caused when the

STORAGE clause has been incorrectly calculated.

If the tablespace in which the TEMPORARY segment resides is of type

PERMANENT, then check that following events are not set in the initalisation

parameter file:

event=”10061 trace name context forever, level 10″

event=”10269 trace name context forever, level 10″

If they are set, comment out the lines and restart database.

These two events prevent SMON from cleaning up TEMP segments and

coalescing. In Oracle Version 7.0, only event 10061 existed and if

set prevented SMON from both cleaning up TEMP segments and coalescing.

From oraus.msg:

10061, 00000, “disable SMON from cleaning temp segments

10269, 00000, “Don’t do coalesces of free space in SMON”

// *Cause: setting this event prevents SMON from doing free space coalesces

As user sessions require space for sorting, they will be allocated temporary

segment(s) from the user’s temporary tablespace. If the user’s temporary

tablespace is of type PERMANENT and these two events are set, then the session

may eventually run out of space and any new sessions requiring space in the

same tablespace may fail with “ORA-1652: unable to extend temp segment by %s

in tablespace %s”.

For performance issues, tablespaces marked as temporary allocate extents

as needed, but the extents are not released or deallocated after the operation

is done. Instead, the extent is simply marked as FREE or available for the

next sort operation. This eliminates the need to continuously allocate and

deallocate extents after every sort operation, hence gaining performance

benefits.

To find out if a TEMP segment is FREE or being USED and also in which

tablespace the segment resides, query the new dynamic performance view

V$SORT_SEGMENT.

For example:

select TABLESPACE_NAME,TOTAL_BLOCKS,USED_BLOCKS,FREE_BLOCKS

from v$sort_segment;

>>> DURING the SORT you will see something like this:

TABLESPACE_NAME TOTAL_BLOCKS USED_BLOCKS FREE_BLOCKS

—————- ———— ———– ———–

TEMP 590 590 0

>>> AFTER the SORT you will see something like this:

TABLESPACE_NAME TOTAL_BLOCKS USED_BLOCKS FREE_BLOCKS

————— ———— ———— ———–

TEMP 590 0 590

This query shows us that during the sort the USED_BLOCK count

increased since we are using the sort extents and after the sort is done the

USED_BLOCK decreased and FREE_BLOCK count increased because the extents got

released back to the sort extent pool.

Use the following guidelines to specify DEFAULT STORAGE:

Set INITIAL=NEXT.Since a process always writes data equal to

SORT_AREA_SIZE to a temporary segment, a good value for the extent

size is (n*s + b)

where: n is a positive integer

s is the value of SORT_AREA_SIZE initialization parameter

b is the value of DB_BLOCK_SIZE initialization parameter

Using this value optimizes temporary segment usage by allowing

sufficient space for a header block and multiple sort run data to be

stored in each extent.

Specify a PCTINCREASE of zero to ensure that all extents are of the

same size.

The MAXEXTENTS parameter only affects a temporary segment if the tablespace

is a PERMANENT tablespace.

Proper calculation of the Default Storage clause parameters will increase

performance and maximize use of storage.

NOTE: By default when a tablespace is created its contents are set to

hold “PERMANENT” objects, (i.e this includes all segments including sort

segment). Sort segments residing in PERMANENT tablespace are

still cleaned up by SMON as before, after the sort is completed. If a

large number of sort segments have been created, SMON may take some

time to drop them.

To make a tablespace hold only temporary objects we need to set the

contents to TEMPORARY, by issuing the following command:

ALTER TABLESPACE TEMPORARY;

and verify this with the following query:

SVRMGR> select TABLESPACE_NAME,CONTENTS from dba_tablespaces;

TABLESPACE_NAME CONTENTS

—————- ———

SYSTEM PERMANENT

RBS PERMANENT

TEMP TEMPORARY

TOOLS PERMANENT

CYN PERMANENT

RBSTMP PERMANENT

Oracle, SQL scripts

Post navigation

Previous Post: Handling LOB data in Oracle
Next Post: find checksum of a file.

Related Posts

  • find_longsql.sql Oracle
  • Difference between SYNC and AFFIRM Oracle
  • Jai Shree Ram Oracle
  • Ports used by Oracle Software Oracle
  • run this before doing any dbchange pvm_pre_change.sql Oracle
  • How to find where datafile is created dbf_info.sql Oracle

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Categories

  • AWS (2)
  • Azure (1)
  • Linux/Unix (149)
  • Oracle (392)
  • PHP/MYSQL/Wordpress (10)
  • Power-BI (0)
  • Python/PySpark (7)
  • RAC (17)
  • rman-dataguard (26)
  • shell (149)
  • SQL scripts (341)
  • Uncategorized (0)
  • Videos (0)

Recent Posts

  • load SPM baseline from cursor cache05-Jun-2025
  • Drop all SPM baselines for SQL handle05-Jun-2025
  • Load SPM baseline from AWR05-Jun-2025
  • Drop specific SQL plan baseline – spm05-Jun-2025
  • findinfo.sql (SQL for getting CPU and Active session info)27-May-2025
  • SQL Tracker by SID sqltrackerbysid.sql22-Apr-2025
  • How to connect to Oracle Database with Wallet with Python.21-Mar-2025
  • JSON/XML Types in Oracle18-Mar-2025
  • CPU Core related projections12-Mar-2025
  • Exadata Basics10-Dec-2024

Archives

  • 2025
  • 2024
  • 2023
  • 2010
  • 2009
  • 2008
  • 2007
  • 2006
  • 2005
  • To find all disk io ( EMC as well as local) Linux/Unix
  • ORA-01220 Oracle
  • DBMS_JOB all example Oracle
  • OPENING A STANDBY DATABASE IN READ-ONLY MODE Oracle
  • DETERMINING WHICH INSTANCE OWNS WHICH SHARED MEMORY & SEMAPHORE SEGMENTS Oracle
  • Distributed Transaction Troubleshooting. Oracle
  • Configure ssh authentications for RAC Oracle
  • findobj.sql Oracle

Copyright © 2025 pvmehta.com.

Powered by PressBook News WordPress theme