Hi Friends,

Continuing from yesterday’s post on Non-clustered Index seek operation, obvious question is what happens if non clustered index does not contain all columns requested by statement(s)? To find an answer to this question, let us modify our query to return AddressLine1, PostalCode as well along with AddressID and StateProvinnceID.



SQL Server query optimizer chosen IX_Address_StateProvinceID to find the records quickly as can be seen in non-clustered index seek operation however the index doesn’t cover additional columns and for the same reason it has to use the clustered index PK_Address_AddressID on the base table to get the additional records. This is performed by SQL Server Key Lookup operator.


When we observe this operator in query plan, in simple words it means that SQL Server query optimizer cannot retrieve the rows in a single go and has to use a clustered key to fetch required rows and in our case it is PK_Address_AddressID. Following is the snapshot of indexes used here in order to fetch required data.


We are going to explore more on this operator in next three days, stay tuned.



Like us on FaceBookJoin the fastest growing SQL Server group on FaceBookFollow me on Twitter | Follow me on FaceBook