How to check index fragmentation and re-create an index in the Oracle database

Source: Internet
Author: User

When the index fragmentation is too large, the query execution speed will be affected, thus affecting our work efficiency. At this time, the most favorable measure is to re-build the index. This article mainly introducesOracle DatabaseMediumCheck Index fragmentationAndRe-IndexingNext we will introduce this process.

The procedure for re-indexing is as follows:

1. Confirm Basic Information

Log on to the database and find the tablespace that stores the index. In this tablespace, all the index owner is tax. the index is stored in an independent tablespace, which is separated from the tablespace of a data table. It is a common database design method.

2. Find which indexes need to be rebuilt

You can use the anlyze index... validate structure command to analyze a single specified index and store the analysis results of a single index to index_stats. The general judgment is based on:

 
 
  1. height >4  
  2.  
  3. pct_used < 50%  
  4.  
  5. del_lf_rows / lf_rows +0.001 > 0.03 

3. googleAll index traversal scripts are downloaded.

Anlyze index found .... validate structure can only fill in the analysis information of a single index, So google runs a Loop script on the Internet to traverse all the index names in the index space, in addition, you can store the analysis information of all indexes in a user table created by yourself.

4. anlyze index lock index

It is found that the downloaded script is not easy to use. We should strive for an exclusive lock for the anlyze index before analyzing the index and lock the index. Obviously, some indexes are being used by the application system, so running anlyze fails. The lesson learned here is to do this at night as much as possible. However, I prefer to go home on time, so I add Exception Handler to the statement and throw the index names that failed anlyze index execution to make the script run properly. Manually perform the index Analysis Based on the index name printed to the foreground.

5. Summary

Although 522 of the 160 indexes match the above judgment. However, the index is not large, and those indexes with millions of leaf do not meet the above judgment conditions. Therefore, the conclusion is that index rebuild online is not required.

6. When can I rebuild the index?

Rebuild index online is helpful for large indexes with a large number of DML operations. You can build a rebuild for a large index every quarter. Usually, even rebuild index online will cause I/O contention, so it is of little significance to have it online. You can put it in 3-5 nights and execute rebuild index in batches to lock the index, when no user is allowed to wait) and the paralle 8 keyword is added, the database server should have eight cpu processors.

This article describes how to check index fragmentation and re-Indexing in the Oracle database. We hope this will help you.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.