4
Deploying, Managing, and Administering the Oracle Internet Platform Paper #267/ Page 1 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. LATCHING BOTTLENECKS CAN OCCUR 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.

8 i locally_mgr_tbsp

Embed Size (px)

Citation preview

Page 1: 8 i locally_mgr_tbsp

Deploying, Managing, and Administering the Oracle Internet Platform

Paper #267/ Page 1

OORRAACCLLEE 88II LLOOCCAALLLLYY--MMAANNAAGGEEDD TTAABBLLEESSPPAACCEESS

Brian Lomasky, DBA Solutions, Inc.

Oracle8i has a new feature for Oracle DBAs, which allows the database to automatically manage the space allocationfor 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 touse it, and how to integrate it into your database schema.

TABLESPACE SPACE MANAGEMENTTablespaces 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 ofeach Oracle block is set when the database is initially created, typically 2048, 4096, or 8192 physical disk bytes perOracle block).Prior to Oracle8i (8.1), there is only one method that Oracle used to manage space within a tablespace. This methodis called “Dictionary-Managed”.As of Oracle8.1, there is an additional method which can be used to manage space within a tablespace. This newmethod is called “Locally-Managed”. Note that the default method is “Dictionary-Managed”, unless you specifyotherwise.The desired method is specified when the tablespace is initially created, and can not be easily changed withoutrebuilding 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 dictionarytables.

• 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 theseobjects.

• This is accomplished by Oracle generating a large amount of recursive SQL.LATCHING BOTTLENECKS CAN OCCUR

• 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.

Page 2: 8 i locally_mgr_tbsp

Deploying, Managing, and Administering the Oracle Internet Platform

Paper #267/ Page 2

TEMPORARY TABLESPACES ALSO REQUIRE SPACE MANAGEMENT

Temporary tablespaces require similar space management as permanent tablespaces, since sorting operations generateredo, 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 avery 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 thedatabase’s tablespaces. Fragmentation is almost always an issue and much time is wasted in controlling and reactingto space and fragmentation problems.

ASPECTS OF LOCALLY-MANAGED SPACESPACE 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 thetablespace. Each bit represents one or more blocks. Bits are set or cleared to indicate whether each extent is allocatedor 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 CREATETABLESPACE statement. (To specify a locally-managed SYSTEM tablespace, you can specify this clause in theCREATE DATABASE statement. This will require that all of the rollback segments also be locally-managed, and ofa uniform size).Along with this clause, you must also choose one of the two extent allocation size methods:AUTOALLOCATEOracle 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 SIZEThis allows you to specify a constant extent size of n bytes, regardless of what is specified by the INITIAL andNEXT clauses of the objects to be created in the tablespace. If you do not specify the size clause, it defaults to 1meg).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 locallymanaged 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 isprimarily used for temporary segments which are created when sorting data.Temporary tablespaces can also be locally-managed by including the EXTENT MANAGEMENT LOCAL andTEMPFILE ‘filespec’ clauses in the CREATE TEMPORARY TABLESPACE statement.

Page 3: 8 i locally_mgr_tbsp

Deploying, Managing, and Administering the Oracle Internet Platform

Paper #267/ Page 3

Having the space managed within the temporary tablespace effectively isolates the temporary tablespace operationsfrom 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 toprotect against data dictionary transaction failure.

NEW DATA DICTIONARY VIEWS

• V$SORT_USAGE Information about sort usage.

• V$TEMPFILE Information about all TEMPFILEs from the control file.

• V$TEMP_EXTENT_MAP Information about all temporary tablespace chunks of space.

• V$TEMP_EXTENT_POOL Summary information about each file's extent map.

• V$TEMP_SPACE_HEADER Information about TEMPFILE file level space management.

CHANGED DATA DICTIONARY VIEWS

• DBA_DATA_FILES New columns (USER_BLOCKS, USER_BYTES) including the space occupied byany bitmaps.

• DBA_EXTENTS New view, which includes the locally-managed used extents.

• DBA_FREE_SPACE New view, which includes the locally-managed free extents.

• DBA_TABLESPACES New columns (EXTENT_MANAGEMENT, ALLOCATION_TYPE) whichindicates the extent allocation type (local or dictionary managed) and allocation method (automatic or uniform, iflocally-managed)

NEW PACKAGES

• DBMS_SPACE_ADMIN This package is created by the $ORACLE_HOME/rdbms/admin/dbmsspace.sqlscript. This package can be used by the DBA to check for bitmap corruption and rebuild the bitmaps. It also canbe used to migrate from locally-managed tablespaces back to the pre-Oracle8.1 dictionary based spacemanagement.

ADVANTAGES OF LOCALLY-MANAGED SPACEThe simplicity of setting or clearing a bit within a bitmap, versus inserting, updating, and deleting extents from variousdata dictionary tables, improves the scalability of the database’s 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 orrollback 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 adjacentfree 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 determinethe optimum size of the extents.Having extents of the same size virtually eliminates any fragmentation concerns by the DBA. This allows extents tobe allocated, deallocated, and then later reused with no wasted space. Unless the number of extents reaches morethan 1000 for a single object, the DBA need not be concerned with reacting to fragmentation issues.

Page 4: 8 i locally_mgr_tbsp

Deploying, Managing, and Administering the Oracle Internet Platform

Paper #267/ Page 4

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

BIBLIOGRAPHYOracle8i ConceptsOracle8i SQL ReferenceOracle8i Administrators GuideOracle8i Supplied Packages Reference

BIOGRAPHYBrian Lomasky is a principal with DBA Solutions, Inc., and is a nationally-certified Oracle DBA. He specializes inOracle8 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 nationalconferences, as well as the Northeast Oracle User’s 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