Skip to Main Content
  • Questions
  • Temporary Tablespace Re-use of previously used blocks

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, John.

Asked: October 13, 2016 - 11:08 pm UTC

Last updated: October 15, 2016 - 1:37 am UTC

Version: 11.2

Viewed 1000+ times

You Asked

Good Evening,

I have a few questions regarding temporary tablespace's efficiency with re-using previously used blocks in the temporary tablespaces. First, can Oracle 11g+ re-use previously used blocks? In other words, if a session needs 900MB of temporary tablespace in the one temporary tablespace with a maxsize of 1gB, completes sorting data at 10am. Then another session performs a sort that required 500MB, will it be able to re-use the temp space or is it possible for it to get an "unable to extend temp segment"?

Is there a command that we can use that will allow us to deallocate any previously used temp blocks? Will a "shrink space keep" perform that operation?

Thanks for your help,

John

and Chris said...

If the first session has finished using temp, then yes another session can re-use this space. Otherwise your temp tablespace would grow indefinitely!

If both sessions need the temp space at the same time, then yes you could get "unable to extend".

Yes, you can use "shrink space keep" to deallocate space from 11.1. Dba_temp_free_space tells you how much is currently in use:

select tablespace_name,
       tablespace_size / 1024 / 1024 sz, 
       allocated_space / 1024 / 1024 asp,
       free_space / 1024 / 1024 fsp
from dba_temp_free_space;

TABLESPACE_NAME  SZ   ASP  FSP  
TEMP             747  747  746 

alter tablespace temp shrink space keep 500M;

select tablespace_name,
       tablespace_size / 1024 / 1024 sz, 
       allocated_space / 1024 / 1024 asp,
       free_space / 1024 / 1024 fsp
from dba_temp_free_space;

TABLESPACE_NAME  SZ   ASP  FSP  
TEMP             500  1    499

Rating

  (1 rating)

Is this answer out of date? If it is, please let us know via a Comment

Comments

A reader, October 14, 2016 - 4:17 pm UTC

Thanks for your help, Chris.

Thanks,

John
Connor McDonald
October 15, 2016 - 1:37 am UTC

Glad we could help