2

I am going through the execution plan of a tsql query.

enter image description here

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.

3

It is not possible to have an INCLUDE column for an index that enforces a constraint. This has been brought up, but marked as "won't fix".

If the benefits of having a covering index are that great, consider revising the indexing strategy that you currently have on that table to maximize query performance.

1

How do we add an INCLUDE in an index which is automatically created (through CONSTRAINTS)?

Answer: INCLUDE (column [ ,... n ] ) represents non key column, Column names cannot be repeated in the INCLUDE list and cannot be used simultaneously as both key and non-key columns.

Check Create Index Arguments--> Include and Create Indexes with Included Columns

I would advice to check different option and plan for indexes that you are looking for

  • I think the OP is asking more about how to get INCLUDE columns when defining a constraint. – Thomas Stringer Sep 16 '14 at 11:31
  • @ThomasStringer, You would be right, but OP need to confirm that we get it right or it mean something else? – vijayp Sep 16 '14 at 12:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.