Key Lookup isn't applied by default?
0
votes
2
answers
236
views
I'm trying to learn about covering indexes. In the Northwind database, I select from the table *Categories*:
As you can see the table has a non-clustered index on the column *CategoryName*.
This SQL query:
select CategoryName from Categories where Categories.CategoryName like 'Beverages'
returns an execution plan with an index seek:
However, this:
select CategoryName ,Description from Categories where Categories.CategoryName like 'Beverages'
returns this execution plan with an index scan using the primary key index, which isn't expected:
I can find the expected behaviour only when I force the query with the non-clustered index:
select CategoryName ,Description from Categories
with(index(CategoryName))
where Categories.CategoryName like 'Beverages'
What is the problem?




Asked by A.HADDAD
(119 rep)
Dec 20, 2020, 01:59 PM
Last activity: Dec 20, 2020, 02:36 PM
Last activity: Dec 20, 2020, 02:36 PM