sql-server - 聚集索引和非聚集索引实际上意味着什么?

标签 sql-server performance indexing clustered-index non-clustered-index

我对 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/

相关文章:

sql-server - 传递 SQL 函数数据库名称

计算所有函数的执行时间

mysql - 该表及其查询的最佳优化是什么?

sql-server - SQL Server 索引顺序(日期时间字段)

mysql - 在虚拟列上创建 mysql 索引时出现问题

c# - T-SQL 表类型,指定类型未注册

c# - 解析 SQL 语句以查看它是否不是 SELECT 语句?

sql-server - tSQLt - 处理多个 SQL Server 结果集

sql-server - XML 服务器 XML 性能优化

.net - 在 .Net 中进行跟踪的工具/最佳实践