Which is better: Bookmark/Key Lookup or Index Scan

后端 未结 3 988
悲&欢浪女
悲&欢浪女 2020-12-13 23:45

I know that an index seek is better than an index scan, but which is preferable in SQL Server explain plans: Index seek or Key Lookup (Book

3条回答
  •  有刺的猬
    2020-12-14 00:02

    Index seek, every time.

    Lookups are expensive, so this is covering indexes and especially the INCLUDE clause was added to make them better.

    Saying that if you expect exactly one row, for example, a seek followed a lookup can be better than trying to cover a query. We rely on this to avoid yet another index in certain situations.

    Edit: Simple talk article: Using Covering Indexes to Improve Query Performance

    Edit, Aug 2012

    Lookups happen per row which is why they scale badly. Eventually, the optimiser will choose a clustered index scan instead of a seek+lookup because it's more efficient than many lookups.

提交回复
热议问题