You are on page 1of 4

Deploying, Managing, and Administering the Oracle Internet Platform

ORACLE 8I LOCALLY-MANAGED TABLESPACES


Brian Lomasky, DBA Solutions, Inc.

Oracle8i has a new feature for Oracle DBAs, which allows the database to automatically manage the space allocation for the database segments and extents. This paper will explain what this new functionality means to the DBA, why it is important to use this feature, when to use it, and how to integrate it into your database schema.

TABLESPACE SPACE MANAGEMENT


Tablespaces are comprised of one or more data files. Space within each data file is allocated of one or more contiguous range of Oracle blocks (called extents). (The size of each Oracle block is set when the database is initially created, typically 2048, 4096, or 8192 physical disk bytes per Oracle block). Prior to Oracle8i (8.1), there is only one method that Oracle used to manage space within a tablespace. This method is called Dictionary-Managed. As of Oracle8.1, there is an additional method which can be used to manage space within a tablespace. This new method is called Locally-Managed. Note that the default method is Dictionary-Managed, unless you specify otherwise. The desired method is specified when the tablespace is initially created, and can not be easily changed without rebuilding the tablespace.

ASPECTS OF DICTIONARY-MANAGED SPACE


PRIMARILY BASED ON DATA DICTIONARY TABLES
All data space within each tablespace is defined as either "used" or "free". Allocation and deallocation of extents causes rows to be inserted/updated/deleted from some data dictionary tables. Free extent information is stored in the FET$ table. Used extent information is stored in the UET$ table. Rollback information is also generated when these tables are updated. Since and rollback segments are part of the database, space management operations must also occur on these objects. This is accomplished by Oracle generating a large amount of recursive SQL. The ST latch is used to control space management operations, in order to avoid deadlock situations. Since there is only one ST latch, there can be only one space management operation occurring at a time. This can become a performance bottleneck. SMON also uses this latch when coalescing free space, which inhibits all other space management operations.

LATCHING BOTTLENECKS CAN OCCUR

Paper #267/ Page 1

Deploying, Managing, and Administering the Oracle Internet Platform

TEMPORARY TABLESPACES ALSO REQUIRE SPACE MANAGEMENT


Temporary tablespaces require similar space management as permanent tablespaces, since sorting operations generate redo, which needs to be managed.

INAPPROPRIATE SIZING DEFAULTS ARE USED


Unless specifically changed, the current default storage of INITIAL 10K NEXT 10K PCTINCREASE 50 is not a very realistic value. (Remember that a default is someone else's idea of how you should design your database which is almost always wrong!)

THE DBA EXPENDS MUCH TIME TO MANAGE THE SPACE


The Database Administrator is frequently required to manually monitor and administer the space usage within the databases tablespaces. Fragmentation is almost always an issue and much time is wasted in controlling and reacting to space and fragmentation problems.

ASPECTS OF LOCALLY-MANAGED SPACE

SPACE MANAGEMENT OCCURS WITHIN THE TABLESPACE

Space is locally managed within the tablespace's data files. This is accomplished by using an internal bitmap within the tablespace to manage the free and used space within the tablespace. Each bit represents one or more blocks. Bits are set or cleared to indicate whether each extent is allocated or free. The FET$ and UET$ tables are not used for locally-managed tablespaces.

CREATING LOCALLY-MANAGED TABLESPACES


When creating the tablespace, include the EXTENT MANAGEMENT LOCAL clause in the CREATE TABLESPACE statement. (To specify a locally-managed SYSTEM tablespace, you can specify this clause in the CREATE DATABASE statement. This will require that all of the rollback segments also be locally-managed, and of a uniform size). Along with this clause, you must also choose one of the two extent allocation size methods:

AUTOALLOCATE
Oracle will calculate the appropriate INITIAL and NEXT sizes for the tablespace's extents (in units of 64K, 1M, 16M, or 64M, as determined by the requested object size). The goal is to best utilize the space, while simplifying the management of the extents. Each bit in the tablespace's bitmap represents a 64K extent, regardless of the calculated size. (This is the default if neither AUTOALLOCATE nor UNIFORM is specified).

UNIFORM SIZE
This allows you to specify a constant extent size of n bytes, regardless of what is specified by the INITIAL and NEXT clauses of the objects to be created in the tablespace. If you do not specify the size clause, it defaults to 1 meg). Each bit in the tablespace's bitmap represents an extent of the specified size. Note that tablespaces using the old dictionary based space management can coexist with ones using the new locally managed space management functionality.

TEMPORARY TABLESPACE SPACE MANAGEMENT


Temporary tablespaces allow for the allocation of schema objects only for the duration of a database session. This is primarily used for temporary segments which are created when sorting data. Temporary tablespaces can also be locally-managed by including the EXTENT MANAGEMENT LOCAL and TEMPFILE filespec clauses in the CREATE TEMPORARY TABLESPACE statement.

Paper #267/ Page 2

Deploying, Managing, and Administering the Oracle Internet Platform

Having the space managed within the temporary tablespace effectively isolates the temporary tablespace operations from the rest of the database. The TEMPFILE clause will cause the temporary tablespace to be recorded only in the control file. Since temporary segments will not be stored in the data dictionary, no redo operations need be generated, in order to protect against data dictionary transaction failure.

NEW DATA DICTIONARY VIEWS


V$SORT_USAGE V$TEMPFILE V$TEMP_EXTENT_MAP V$TEMP_EXTENT_POOL V$TEMP_SPACE_HEADER DBA_DATA_FILES any bitmaps. DBA_EXTENTS DBA_FREE_SPACE Information about sort usage. Information about all TEMPFILEs from the control file. Information about all temporary tablespace chunks of space. Summary information about each file's extent map. Information about TEMPFILE file level space management.

CHANGED DATA DICTIONARY VIEWS


New columns (USER_BLOCKS, USER_BYTES) including the space occupied by New view, which includes the locally-managed used extents. New view, which includes the locally-managed free extents.

DBA_TABLESPACES New columns (EXTENT_MANAGEMENT, ALLOCATION_TYPE) which indicates the extent allocation type (local or dictionary managed) and allocation method (automatic or uniform, if locally-managed) DBMS_SPACE_ADMIN This package is created by the $ORACLE_HOME/rdbms/admin/dbmsspace.sql script. This package can be used by the DBA to check for bitmap corruption and rebuild the bitmaps. It also can be used to migrate from locally-managed tablespaces back to the pre-Oracle8.1 dictionary based space management.

NEW PACKAGES

ADVANTAGES OF LOCALLY-MANAGED SPACE


The simplicity of setting or clearing a bit within a bitmap, versus inserting, updating, and deleting extents from various data dictionary tables, improves the scalability of the databases space management operations. The bitmap operations do not generate any rollback information, since no tables are updated in the data dictionary (except for such special cases as tablespace quota operations). Recursive operations are eliminated, since no space management will be required on the data dictionary tables or rollback segments. Less reliance upon the data dictionary is required, improving overall database reliability. The local management of extents automatically tracks adjacent free space, eliminating the need to coalesce adjacent free extents (since adjacent bits marked free in the bitmap are treated as a single group of free blocks). Extent sizes can be automatically calculated by Oracle, freeing the DBA and/or developer from having to determine the optimum size of the extents. Having extents of the same size virtually eliminates any fragmentation concerns by the DBA. This allows extents to be allocated, deallocated, and then later reused with no wasted space. Unless the number of extents reaches more than 1000 for a single object, the DBA need not be concerned with reacting to fragmentation issues.

Paper #267/ Page 3

Deploying, Managing, and Administering the Oracle Internet Platform

SUMMARY
The new locally-managed tablespace functionality within Oracle frees the DBA from having to frequently manage the size and number of extents within each tablespace, as well as reacting to fragmentation concerns. It also enables the easy implementation and usage of transportable and read-only tablespaces. Oracle's internal space management routines have been simplified, reducing the number of recursive SQL, rollback, redo, and latch contention that is generated, thereby increasing database performance.

BIBLIOGRAPHY
Oracle8i Concepts Oracle8i SQL Reference Oracle8i Administrators Guide Oracle8i Supplied Packages Reference

BIOGRAPHY
Brian Lomasky is a principal with DBA Solutions, Inc., and is a nationally-certified Oracle DBA. He specializes in Oracle8 and Oracle7 Database Administration and Unix/OpenVMS/WinNT operating system tuning, troubleshooting, configuration, backup and recovery, and database auditing. He has presented numerous sessions at the International Oracle User Group and Oracle Openworld national conferences, as well as the Northeast Oracle Users Group. Brian Lomasky is the author of the best-selling "Oracle Scripts" book, published by O'Reilly & Associates, Inc. Copyright 1999 by DBA Solutions, Inc., 86 Lancaster Rd, Arlington, MA 02476. (781) 648-0788

Paper #267/ Page 4

You might also like