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?