Reputation: 6073
I am going through the execution plan of a tsql
query.
There is a key LookUp (Clustered)
in the plan. To avoid this Key LookUp
, I tried to Include a column (Status_Ind
) to The Index (The Index used in execution plan). But I realize that optimizer is using two Indexes, One the Primary Key index and the 2nd one, an index automatically created as a part of a Constraint (A UNIQUE NONCLUSTERED Index). I find no way to add an include part in this Index.
How do we add an INCLUDE in an index which is automatically created (through CONSTRAINTS)? I am really a beginner in Query optimization..
Upvotes: 2
Views: 47
Reputation: 32707
If you find that the key lookup is really a big deal (and it may or may not be), you can create a unique index instead of a unique constraint. In SQL Server, the two are the same (unique constraints are enforced via a unique index). You can place include columns on a unique index, so you should be set.
Upvotes: 1