How to Determine When an Index Should be Rebuilt?
APPLIES TO:
Oracle Database - Enterprise Edition - Version 8.1.7.3 to 11.2.0.3 [Release 8.1.7 to 11.2]Information in this document applies to any platform.
< Checked for currency 24-Sep-2014>
GOAL
How to determine when an index should be rebuilt?
Please note that the reason to rebuild an index should be because of poor performance of your queries using the index.
You should/must not rebuild indexes if you find the results for both relevant queries in 1. and 2. true for an index but that is not accompanied by poor SQL performance.
For a more current approach, please refer to
Note 989093.1 - Index Rebuild, the Need vs the Implications
This Note 1373415.1 has been archived in favor of Note 989093.1
SOLUTION
1- Find indexes having height(blevel+1) > 4
i.e. Indexes having BLEVEL > 3
2- Analyze indexes to find ratio of (DEL_LF_ROWS/LF_ROWS*100) is > 20 by "analyzing the index with validate structure option" and then:
As already stated, the blevel is not always an indication for a bad index. Please refer to Note 989093.1
However, rebuilding an index may help performance in specific cases.
See this example:
Index analyzed.
SQL> SELECT name,height,lf_rows,lf_blks,del_lf_rows FROM INDEX_STATS;
NAME HEIGHT LF_ROWS LF_BLKS DEL_LF_ROWS
------------ ---------- ---------- ----------- -------------
TEST_INDX 8 938752 29575 73342
You can see height of the index is 8 and also high number of DEL_LF_ROWS.
SQL> set timing on
SQL>
SQL> select count(*) from TEST_TABLE where TEST_COL like '%';
COUNT(*)
----------
39700
Elapsed: 00:00:27.25
Execution Plan
----------------------------------------------------------
Plan hash value: 870163320
Id Operation Name Rows Bytes Cost (%CPU) Time
0 SELECT STATEMENT 1 117 10 (0) 00:00:01
1 SORT AGGREGATE 1 117
*2 INDEX RANGE SCAN TEST_INDX 115 13455 10 (0) 00:00:01
Statistics
----------------------------------------------------------
1 recursive calls
0 db block gets
764 consistent gets
757 physical reads
0 redo size
516 bytes sent via SQL*Net to client
468 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processed
Now you rebuild the indexes
SQL> alter index TEST_INDX rebuild;
Index altered.
SQL> select count(*) from TEST_TABLE where TEST_COL like '%';
COUNT(*)
----------
39700
Elapsed: 00:00:06.18
Execution Plan
----------------------------------------------------------
Plan hash value: 870163320 - See here although it is using the same plan but still it is faster
Id Operation Name Rows Bytes Cost (%CPU) Time
----------------------------------------------------------------------------------
0 SELECT STATEMENT 1 117 6 (0) 00:00:01
1 SORT AGGREGATE 1 117
* 2 INDEX RANGE SCAN TEST_INDX 115 13455 6 (0) 00:00:01
Statistics
----------------------------------------------------------
15 recursive calls
0 db block gets
592 consistent gets
588 physical reads
0 redo size
516 bytes sent via SQL*Net to client
468 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
SQL> SELECT name,height,lf_rows,lf_blks,del_lf_rows,distinct_keys,used_space FROM INDEX_STATS;
NAME HEIGHT LF_ROWS LF_BLKS DEL_LF_ROWS
------------------------------ ---------- ---------- ---------- -----------
TEST_INDX 4 865410 15434 0
This clearly indicates the rebuilt OF THE INDEX helped the query performance in this particular situation.
The height of index is reduced to 4 and DEL_LF_ROWS is 0
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/628922/viewspace-1426554/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- ORA-14086: a partitioned index may not be rebuilt as a wholeIndexUI
- AIX: HOW TO DETERMINE WHICH VERSION OF HACMP IS INSTALLED [ID 1057292.6]AIACM
- How to Find Out How Much Space an Index is UsingIndex
- How determine the RC time constant in PWM DAC low-pass filter?Filter
- How does the system determine the quantity structure for the cost estimate (CK11N)?Struct
- DNS 靈魂三問:why,when,howDNS
- What are general rules when deciding on index?Index
- How to Specify an INDEX Hint oracle官方文件IndexOracle
- Oracle vs PostgreSQL Develop(30) - Index&Case whenOracleSQLdevIndex
- ORA-08104: this index object 93996 is being online built or rebuiltIndexObject996UI
- Python, pandas: how to sort dataframe by index// Merge two dataframes by indexPythonIndex
- When should reread of cl_crm_bol_entity and $scope.$apply be called manuallyAPP
- Linguistics-English-Would, Should, and Could: How to Use Them CorrectlyNGUI
- ORA-08104: this index object %s is being online built or rebuilt的處理IndexObjectUI
- [原創] How to pull code when shared repo commit history has been changedMIT
- How to resolve ORA-19706 error when select from dblinkError
- OGG How to handle / replicate tables with no (without) primary key (PK) or unique index (UI) (UPI) [IndexUI
- 【我的Android進階之旅】解決重寫onTouch事件提示的警告:onTouch should call View#performClick when a click is detectedAndroid事件ViewORM
- 6 Thing that determine composite cost
- TextInput should be given height
- What database aspects should be monitored?Database
- Starting httpd: httpd: Could not reliably determine the serverhttpdServer
- The ITer should learn more about ITIL
- Why Startups Should Not Choose NoSQLSQL
- [ERROR]XX is marked as crashed and should be repairedErrorAI
- 遭遇 comp... be showing ... determine its location
- ORACLE CASE WHEN 及 SELECT CASE WHEN的用法Oracle
- Oracle Case WhenOracle
- SQL Case WhenSQL
- When to Partition a Table
- What you should know about JavaJava
- IBM WAS Service--Could not determine the process id of the javaprocess.IBMJava
- 實體類註解錯誤:Could not determine type for:
- The DBA_TABLESPACE_USAGE_METRICS View Needs to be Rebuilt in 10g_738101.1ViewUI
- Should i install mail server on local machine?AIServerMac
- [Cexpert-003] You should remember some of ASCII!REMASCII
- Why should we copy blocks rather than retain?BloCAI
- KEEP INDEX | DROP INDEXIndex