question

srizwanh avatar image
srizwanh asked

Index usage in query plan

If PK is on ID and non-clustered index (IX_1) is on First, Last, and Age, and Would query "Select Age from Users where ID = 24" use IX_1 or would it go PK and do row scan on PK
sql serverexecution-plannonclustered-index
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
JohnM avatar image
JohnM answered
My initial guess, assuming your primary key is also your clustering key, is that it would do a clustered index seek since that's the primary key it should do a seek to locate the record. The Age is already included in the clustered index since that's essentially the table anyway. If the table is small, it's possible that it would do a clustered index scan so that's a potential. Why not try it and see what it does?
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Thanks for the info... I will give it a try.
0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.