我对 DB 的接触有限,并且仅作为应用程序员使用过 DB。我想了解聚集
和非聚集索引
。
我用谷歌搜索,发现的是:
A clustered index is a special type of index that reorders the way records in the table are physically stored. Therefore table can have only one clustered index. The leaf nodes of a clustered index contain the data pages. A nonclustered index is a special type of index in which the logical order of the index does not match the physical stored order of the rows on disk. The leaf node of a nonclustered index does not consist of the data pages. Instead, the leaf nodes contain index rows.
我在SO中发现的是What are the differences between a clustered and a non-clustered index? .
有人能用简单的英语解释一下吗?
最佳答案
对于聚集索引,行以与索引相同的顺序物理存储在磁盘上。因此,聚集索引只能有一个。
对于非聚集索引,还有第二个列表,其中包含指向物理行的指针。您可以拥有许多非聚集索引,尽管每个新索引都会增加写入新记录所需的时间。
如果您想取回所有列,从聚集索引读取通常会更快。您不必先访问索引,然后再访问表。
如果需要重新排列数据,写入具有聚集索引的表可能会更慢。
关于sql-server - 聚集索引和非聚集索引实际上意味着什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43949210/