Does the SQL Server clustered index replace the RID lookup “index”

前端 未结 3 1951
Happy的楠姐
Happy的楠姐 2021-01-04 06:51

When a table has a clustered index in SQL Server does that mean that all indexed queries will go via the clustered index?

For example if I have a table with a single

3条回答
  •  借酒劲吻你
    2021-01-04 07:41

    No. Not every query will use the clustered index. If a query is "covered" by a nonclustered index (all the columns required for the query are contained in the NC index) then SQL Server will only need to read those index pages and not perform the bookmark lookup. In fact the optimizer will often prefer to use a covering NC index whenever it can because the NC index is usually smaller than the clustered index and is therefore usually faster to scan.

提交回复
热议问题