Cluster factor (clustering Factor)

Source: Internet
Author: User

Clustering factor is a statistic used by the CBO to measure whether a column in a table is stored in a regular sort order.

When accessing a table through an index, it is used as an indicator of cost evaluation. When scanning the index, clustering factor records the number of data blocks that need to be accessed.

You can view clustering factor in the following data dictionary:

-all| dba| user_indexes-all| dba| user_ind_partitions-all| dba| User_ind_subpartitions

How to calculate clustering factor:

1. Scan the index sequentially (the block number corresponding to the record can be found by Dbms_rowid.rowid_block_number (ROWID). rowID is recorded in the index, so Oracle can determine whether the record is in the same block based on the ROWID in the index. 2. The block number in the rowid of the current index row is compared to the block number in the rowid of the previous index row (that is, the block number in the adjacent rowID is compared) 3. If the block number in the ROWID is different, clustering Factor counter plus 14. This compares all indexes 5. The final count result is the value of the clustering factor.

For example, for instance, there are a,b,c,d,e five records in the index, first compare whether a, B is in the same block, if not the same block, then clustering factor+1, and then continue to compare b,c same, if B,c is not the same block, So clustering factor+1, so keep going until you compare all the records. According to the algorithm, we can know that the value of clustering factor is between block number and table row number. If the clustering factor is close to the block number, the table storage and index storage ordering is close, that is, the table records are very orderly, so when the index range scan can be, read a small number of data block can get what we want, the cost is relatively small. If the clustering factor is close to the table record count, the storage and index sorting of the table is very different, and when you do the index range scan, additional blocks are read because the table records are fragmented and expensive.

Cluster factor (clustering Factor)

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.