标签:os io for ar sp new on ad ef
An index is used to speed up searching in the database.
By default, when you create this table, your data will be stored on disk and sorted by the "Id" primary key column. This default sort is called the "Clustered Index".
With a clustered index the rows are stored physically on the disk in the same order as the index. There can therefore be only one clustered index.
But if you search by other non-primary key columns most of the time on this table, then you might want to consider changing the clustered index to this column instead.
There a few things to keep in mind when changing the default clustered index in a table:
Non-clustered indexes are not copies of the table but a sorting of the columns you specify that "point" back to the data pages in the clustered index. With a non clustered index there is a second list that has pointers to the physical rows. You can have many non clustered indexes, although each new index will increase the time it takes to write new records.
It is generally faster to read from a clustered index if you want to get back all the columns. You do not have to go first to the index and then to the table.
Writing to a table with a clustered index can be slower, if there is a need to rearrange the data.
小总:Clustered index意思是在选取某个column A,以它排序来存储table里的所有records,所以当你以A为选择条件来做query的时候,因为physically records locate in the same order as the index,通过clustered index可以很快找到符合条件的records。
Non-clustered index意思是比如还是column A,index会存储A的值以及a pointer to the in the table where that value is actually stored.而clusterd index会在leaf node里存储整条record。所以clustered index会更快。
标签:os io for ar sp new on ad ef
原文地址:http://www.cnblogs.com/chayu3/p/3935883.html