Table structure and total records
Let’s look at our table structure as shown in the left panel of the picture
Note: There is a non-clustered index
on the Title
column of the Book
table, which has a total of 1 million records.
select
Id,
Title,
Author,
Price
from Book where title='The Divine Comedy'
As you have noticed in the execution plan, there is a key lookup. Since index is only available for the Title
column, Title
is retrieved from the non-clustered index. However, other columns like Id
, Author
and Price
are not present in the non-clustered index, so they will be retrieved from the clustered index (the Book
table). This results in an additional key lookup
step and may decrease the performance. It’s like, you are looking for records in two places (non clustered index and clustered index).