Symptom
FAQ, frequently asked questions Solution
The term 'space utilization' refers to the percentage of available space that is actually filled with user data. You can evaluate the space utilization on different levels (file system, tablespace, segment, block). For detailed information about the logical components of the Oracle database, such as tablespaces, segments, and extents, refer to Note 666061. The term 'fragmentation' refers to unused space in the database that cannot be used for technical reasons. Frequently, the effects of fragmentation are responsible for poor space utilization.
The term 'block fragmentation' refers to the average space utilization in an Oracle block. Depending on the segment type in question, the following subtypes occur :
The term 'index fragmentation' refers to block fragmentation in an index tree. Index fragmentation is caused by repeatedly deleting and entering data, in particular if you usually delete the entries on one side of the index and make new entries on the other side. For more information, refer to Note 771929 . Index fragmentation also occurs when you delete a large number of table entries and therefore the index entries are deleted as well.
The term 'table fragmentation' refers to block fragmentation in a table. Table fragmentation mainly occurs when you delete a large amount of data from a table. After the deletion, the blocks that are still allocated contain considerably less data than before, which leads to poorer space utilization.
LOB columns are generally paged out into separate LOB segments (see Note 500340). Unfavorable space utilization in an LOB segment is often caused by the fact that a lot of undo information is stored in the segment itself. To limit the scope of retained undo information, make sure that PCTVERSION storage parameter is not set too high. Default value 10 is usually sufficient.
Tablespace fragmentation occurs if a tablespace contains a large number of small freespace areas that cannot be reused due to their size. Tablespace fragmentation is mainly a DMTS problem. Due to the AUTOALLOCATE and UNIFORM assignment strategies, fragmentation effects rarely occur in LMTS (see Note 214995).
Space utilization in the file systems of the Oracle data files does not affect the datafiles directly, but it may be critical due to the cost of disk space. If the file system is configured considerably larger than the datafiles contained in the file system, a lot of space is wasted.
Due to the poor utilization of the existing space, the database requires more space.
The more space required by the database, the longer the runtimes for operations such as Backup and Restore.
If indexes are fragmented, SEVERE performance problems may occur when you access the indexes.
Table fragmentation may also have a negative effect on system performance when the relevant tables are accessed. However, in general, the consequences are less severe than in the case of index fragmentations.
The poorer the space in index and table blocks is utilized, the more blocks need to be loaded into the Oracle buffer pool during the data access. As a result, more blocks of other segments are displaced. These blocks must be reloaded into the buffer later, which generally impairs database performance.
Often, the disk space used incurs costs. These costs increase with the amount of disk space required.
You can determine the index fragmentation by determining the index storage quality or the deleted leaf rows as described in Note 771929.
You can use the following statement to determine the tables with the - in absolute figures - largest unused space: SELECT * FROM (SELECT SUBSTR(TABLE_NAME, 1, 21) TABLE_NAME, NUM_ROWS, AVG_ROW_LEN ROWLEN, BLOCKS, ROUND((AVG_ROW_LEN + 1) * NUM_ROWS / 1000000, 0) NET_MB, ROUND(BLOCKS * (8000 - 23 * INI_TRANS) * (1 - PCT_FREE / 100) / 1000000, 0) GROSS_MB, ROUND((BLOCKS * (8000 - 23 * INI_TRANS) * (1 - PCT_FREE / 100) - (AVG_ROW_LEN + 1) * NUM_ROWS) / 1000000) "WASTED_MB" FROM DBA_TABLES WHERE NUM_ROWS IS NOT NULL AND OWNER LIKE 'SAP%' AND PARTITIONED = 'NO' AND (IOT_TYPE != 'IOT' OR IOT_TYPE IS NULL) ORDER BY 7 DESC) WHERE ROWNUM <=20; The above query is based on statistics values such as BLOCKS or NUM_ROWS. For correct results, you must therefore ensure that the statistics are up-to-date. The system ignores tables without statistics. Statistics created with DBMS_STATS did not take LONG, LONG RAW, and LOB columns into account correctly. For this reason, these tables can be displayed as highly fragmented. This is incorrect. For segments in ASSM tablespaces, you can create a segment dump that displays the levels to which the individual segment blocks are filled (this level is defined in the bitmap blocks). To do this, proceed as follows: SELECT HEADER_FILE, HEADER_BLOCK FROM DBA_SEGMENTS WHERE SEGMENT_NAME = '<segment_name>'; EXEC DBMS_SPACE_ADMIN.SEGMENT_DUMP('<tablespace_name>', <header_file_from_above>, <header_block_from_above>); You can also use BRCONNECT to create statistics for space utilization. For more information, see Note 554031. As of Oracle 10g, the DBMS_SPACE function (described in Note 1295200) for determining table fragmentation is available. The Oracle Segment Advisor (Note 927813) is also based on this function and therefore can be used to determine fragmentation.
You can use DBMS_LOB.GETLENGTH to determine the space used within an LOB segment. You can use the following script to determine the net allocation of the existing LOB segments: connect <sapuser>/<password> SET HEADING OFF SET FEEDBACK OFF SET ECHO OFF SET PAGESIZE 50000 SET SQLPROMPT '' SPOOL lob.sql SELECT 'SELECT ''' || TABLE_NAME || ''' TABLE_NAME, ''' || COLUMN_NAME || ''' COLUMN_NAME, ROUND(SUM(DBMS_LOB.GETLENGTH("' || COLUMN_NAME || '")) / 1024 / 1024) "NET (MB)" FROM "' || USER || '"."' || TABLE_NAME || '";' FROM USER_LOBS; SPOOL OFF COLUMN TABLE_NAME FORMAT A30 COLUMN COLUMN_NAME FORMAT A25 SET HEADING ON @lob SET FEEDBACK ON SET SQLPROMPT 'SQL>' In the next step, you can compare the net demand determined in this way with the BYTES value from DBA_SEGMENTS, if you suspect the space is being utilized poorly.
To determine the number of unused space fragments in a table space and their breakdown into different sizes, proceed as follows: SELECT BLOCKS, COUNT(*) FROM DBA_FREE_SPACE WHERE TABLESPACE_NAME = '<tablespace_name>' GROUP BY BLOCKS ORDER BY BLOCKS;
You can use the following statement to determine all tables that have more than 1,000 unused blocks: SELECT TABLE_NAME FROM DBA_TABLES WHERE EMPTY_BLOCKS > 1000;
As of Oracle 10g, you can use the Oracle Segment Advisor for a general analysis of segments, such as tables, indexes, or LOBs. For more information, see Note 927813.
You can use REBUILD, COALESCE or DROP and CREATE to eliminate index fragmentation. If you want to use these functions, refer to Notes 771929 and 332677 for more information.
Allocated blocks are usually poorly utilized after you have deleted large volumes of data from the table (for example, while archiving). If you know that the size of the table will in future be similar to its size before you deleted the data, you do not have to intervene. However, if the table will permanently have less data, you can reconstruct it during a reorganization to reduce table fragmentation (see Note 541538). As of Oracle 10g, you also have the option of using Segment Shrinking (Note 910389). Refer to Note 572060 for more information. If the fragmentation has LONG RAW fields due to the Oracle response described in Note 830965, refer to the solutions listed there. If an ASSM segment requires an unnecessary amount of space because the levels of filled space defined in the bitmap blocks do not reflect reality, and because they accept blocks that are far too full (for example, due to Oracle bugs), you can correct the inconsistencies as follows: EXEC DBMS_REPAIR.SEGMENT_FIX_STATUS('<owner>','<segment_name>'); After you have done this, all free areas can be used again productively. For more information, see Note 896717.
You can clean up LOB segment fragmentation by carrying out a reorganization (of the relevant table) and, where necessary, by reducing PCTVERSION (recommended: <= 10).
If tablespaces are fragmented in DMTS due to a large number of small areas of unused space, you can use COALESCE to combine adjacent areas of unused space: ALTER TABLESPACE <tablespace_name> COALESCE; Note that this operation may cause problems with the ST enqueue if there are a lot of areas with unused space (see Note 745639). If the number of areas with unused space remains high after a COALESCE, you can defragment the tablespace by reorganizing it (see Note 541538). To reduce tablespace fragmentation, we recommend that you use the "brconnect -f next" function to choose adequate sizes for the NEXT extent for growing segments. This way, you can keep fragmentation to a minimum. In the medium-term and the long-term, you can reduce tablespace fragmentation by changing to LMTS (see Note 214995).
Alternatively, you can also reduce the size by reorganizing the tablespaces (with data files).
|
Related Notes | |
---|---|
1295200 | Oracle 10g or higher: Space statistics based on DBMS_SPACE |
1010237 | Growth of DYNPSOURCE table after Unicode migration |
948197 | Merge fix for DBMS_STATS package on Oracle 9.2.x and 10.2.x |
927813 | Oracle 10g: Using Oracle Segment Advisor to optimize space |
910389 | FAQ: Oracle Segment Shrinking |
896717 | Problems with tables in ASSM tablespaces |
832343 | FAQ: Clustering factor |
771929 | FAQ: Index fragmentation |
745639 | FAQ: Oracle enqueues |
666061 | FAQ: Database objects, segments and extents |
No comments:
Post a Comment