05.11.2015 Views

Apress.Expert.Oracle.Database.Architecture.9i.and.10g.Programming.Techniques.and.Solutions.Sep.2005

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CHAPTER 3 ■ FILES 95<br />

dictionary tables. However, once an extent was allocated in a temporary tablespace, the system<br />

would hold on to it (i.e., it would not give the space back). The next time someone<br />

requested space in the temporary tablespace for any purpose, <strong>Oracle</strong> would look for an<br />

already allocated extent in its internal list of allocated extents. If it found one there, it would<br />

simply reuse it, or else it would allocate one the old-fashioned way. In this manner, once the<br />

database had been up <strong>and</strong> running for a while, the temporary segment would appear full but<br />

would actually just be “allocated.” The free extents were all there; they were just being managed<br />

differently. When someone needed temporary space, <strong>Oracle</strong> would look for that space in<br />

an in-memory data structure, instead of executing expensive, recursive SQL.<br />

In <strong>Oracle</strong> 8.1.5 <strong>and</strong> later, <strong>Oracle</strong> goes a step further in reducing this space management<br />

overhead. It introduced the concept of a locally-managed tablespace as opposed to a dictionarymanaged<br />

one. Local management of space effectively did for all tablespaces what <strong>Oracle</strong> 7.3<br />

did for temporary tablespaces: it removed the need to use the data dictionary to manage<br />

space in a tablespace. With a locally-managed tablespace, a bitmap stored in each data file is<br />

used to manage the extents. Now to get an extent, all the system needs to do is set a bit to 1<br />

in the bitmap. To free space, the system sets a bit back to 0. Compared to using dictionarymanaged<br />

tablespaces, this is incredibly fast. We no longer serialize for a long-running<br />

operation at the database level for space requests across all tablespaces. Rather, we serialize<br />

at the tablespace level for a very fast operation. Locally-managed tablespaces have other nice<br />

attributes as well, such as the enforcement of a uniform extent size, but that is starting to get<br />

heavily into the role of the DBA.<br />

Going forward, the only storage management method you should be using is a locallymanaged<br />

tablespace. In fact, in <strong>Oracle</strong>9i <strong>and</strong> above, if you create a database using the<br />

database configuration assistant (DBCA), it will create SYSTEM as a locally-managed tablespace,<br />

<strong>and</strong> if SYSTEM is locally managed, all other tablespaces in that database will be locally managed<br />

as well, <strong>and</strong> the legacy dictionary-managed method will not work. It is not that dictionarymanaged<br />

tablespaces are not supported in a database where SYSTEM is locally managed, it is<br />

that they simply cannot be created:<br />

ops$tkyte@ORA10G> create tablespace dmt<br />

2 datafile '/tmp/dmt.dbf' size 2m<br />

3 extent management dictionary;<br />

create tablespace dmt<br />

*<br />

ERROR at line 1:<br />

ORA-12913: Cannot create dictionary managed tablespace<br />

ops$tkyte@ORA10G> !oerr ora 12913<br />

12913, 00000, "Cannot create dictionary managed tablespace"<br />

// *Cause: Attempt to create dictionary managed tablespace in database<br />

// which has system tablespace as locally managed<br />

// *Action: Create a locally managed tablespace.<br />

This is a positive side effect, as it prohibits you from using the legacy storage mechanism,<br />

which was less efficient <strong>and</strong> dangerously prone to fragmentation. Locally-managed tablespaces,<br />

in addition to being more efficient in space allocation <strong>and</strong> de-allocation, also prevent<br />

tablespace fragmentation from occurring. This is a side effect of the way space is allocated <strong>and</strong><br />

managed in locally-managed tablespaces. We’ll take an in-depth look at this in Chapter 10.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!