Oracle-index clustering factor

Source: Internet
Author: User

The index clustering factor is a key statistic that can improveboth the Oracle optimizer's performance, and the technician 'sunderstanding of the utility of an index.

It is used by Oracle's optimizer to help determine the costassociated with index range scans in comparison to full tablescans.

Calculating the clustering factor

To calculate the clustering factor of an index during the gatheringof index statistics, Oracle does the following.

For each entry in the index Oracle compares the entry's table rowidblock with the block of the previous index entry.

If the block is different, Oracle increments the clustering factorby 1.

The minimum possible clustering factor is equal to the number ofblocks identified through the index's list of rowid's -- for anindex on a column or columns conatining no Nulls, this will beequal to the number of blocks in the table that contain data. themaximum
Clustering factor is the number of entries in theindex.

Interpreting the clustering factor

So this means that Oracle now has a statistic to allow it toestimate how should table blocks wocould be associated with an indexrange scan.

If the clustering factor is close to the number of entries in theindex, then an index range scan of 1000 index entries may requirenearly 1000 blocks to be read from the table.

If the clustering factor is close to the number of blocks in thetable, then an index range scan of 1000 index entries may requireonly 50 blocks to be read from the table.

This can be compared with the cost of reading the entire table upto the high-water mark (using the more efficient multiblock I/omechanic) to determine whether a full table scan or an index rangescan offers the most efficient access mechanic.

Note that where extensive deletes have occurred from the tablethere may be blocks with no rows in. these will be accounted for inthe clustering factor because those blocks will not appear in theindex's rowid list. the full table scan will still read all tableblocks
Up to the high water mark, regardless of whether theycontain rows or not. so in an extreme case it is possible thatoracle cocould see from the index and table statistics that althougha table has 1,000,000 blocks below the high water mark, reading100 % of
Rows in the table might only require reading 10 ofthose blocks. providing that "not null" constraints tell oraclethat all table rows are present in the index, a query such as "select * From big_table_with_few_rows" might be more efficientlysatisfied with
Index range scan than with a full tablescan.

Note also that calculating the clustering factor is done withoutreference to the table at all -- it is based solely on informationcontained in the index.

Related Article

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.