[Reprint] clustered index and non-clustered index

Clustered index and non-clustered index

Disclaimer: This article is a blogger original article, follow the  CC 4.0 BY-SA  copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/huashanlunjian/article/details/84461527
Clustered index and non-clustered index
 
Clustered index: physical storage table sorted index order.
Non-clustered index: physical storage table is not sorted index order.
Clustered index: when inserting data slower (time spent on "sort of physical storage", that is, we must first find the position and insert). But the scope of the query data faster than non-aggregated data.
 
Why clustered index range query fast is it? ORACLE is used here to illustrate clustering factor.
 
Clustering factor (CLUSTERING_FACTOR)
 
ORACLE clustering factor is used to indicate the degree of similarity table order and the order index. Clustering factor is smaller, the higher the degree of similarity, clustering factor, the lower the similarity. 
 
When the clustering factor is high, indicating that index entry (rowid) block is a random number of points, when a large index range scan, so that in order to read these points rowid block, it is necessary to repeat once again read the block . When the low clustering factor value is, the index keys (rowid) is directed in the same record is stored in the block, so when the read row, only need to read it in the same block. Can reduce the number of block read repeatedly.
 
Obviously, the clustered index clustering factor is the lowest of all indexes, so the clustered index range queries faster than non-clustered index number.
 
Index Organized Tables
 
Oracle is not the so-called clustered index, but the index-organized table (IOT). Oracle table that is common heap table, without sequentially store data at all, and the tissue Oracle index table is a data table stored in primary key sequence. Like the index structure and index-organized tables, but the general index put the key index of the column, and index-organized table data put the entire table. Regularly updated list of course is not suitable IOT, because the oracle requires constant maintenance of the index, and because the cost of multiple indexes on the big field. If not often use the master key to access the table, do not use the IOT.

Guess you like

Origin www.cnblogs.com/jinanxiaolaohu/p/11840827.html