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.

2 Answers 2

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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.