|
|
|
SSC-Dedicated
           
Group: General Forum Members
Last Login: Today @ 2:26 PM
Points: 37,669,
Visits: 29,922
|
|
Charles Kincaid (11/18/2009) When talking about included columns one would guess that the order is no more or less important than the column order in the table itself.
Indeed. Order for included columns is irrelevant, they're only at the leaf level, they cannot be used for seeks. Just the same as the non-key columns for a clustered index.
Gail Shaw Microsoft Certified Master: SQL Server 2008, MVP SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
We walk in the dark places no others will enter We stand on the bridge and no one may pass
|
|
|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Thursday, December 20, 2012 1:03 PM
Points: 265,
Visits: 589
|
|
Great series Gail.
Wondering if you had any thoughts about this: Say I have a non-unique, non-clustered index with some included columns. It covers a bunch of frequently used queries. I could make it an unique index if I add another column to the index, assuming unique indexes are better than non-unique ones. Without more info, what's your instinct: add the column to make the index unique or don't add more than necessary. And, what if that column also happens to be part of the clustered index for that the underlying table? Would that alter your recommendation?
|
|
|
|
|
Hall of Fame
       
Group: General Forum Members
Last Login: Tuesday, May 14, 2013 4:11 PM
Points: 3,390,
Visits: 3,403
|
|
| Good question which reminds me of something similar. The Tuning Adviser often recommends that a column which is also a part of the Clustered index be added as an included column. I do not do this since I assume that it is included in the index anyway. Would including such a column make the index larger for no apparent gain?
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Wednesday, November 18, 2009 2:52 PM
Points: 1,
Visits: 0
|
|
this makes it so much easier to understand how it works. thanks!
DJ
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Today @ 7:06 AM
Points: 7,
Visits: 52
|
|
| Great read! Well written and informative.
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Yesterday @ 4:14 PM
Points: 171,
Visits: 1,397
|
|
Thanks for this series, Gail. I have really enjoyed reading it and found it very informative.
Cheers!
Nicole Bowman
Nothing is forever.
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Wednesday, November 18, 2009 4:39 PM
Points: 1,
Visits: 0
|
|
i dunno. This kind of confused me.
Jason
|
|
|
|
|
SSChampion
        
Group: General Forum Members
Last Login: Friday, May 17, 2013 12:22 PM
Points: 10,571,
Visits: 11,871
|
|
|
|
|
|
SSC-Dedicated
           
Group: General Forum Members
Last Login: Today @ 2:26 PM
Points: 37,669,
Visits: 29,922
|
|
sjsubscribe (11/18/2009) Say I have a non-unique, non-clustered index with some included columns. It covers a bunch of frequently used queries. I could make it an unique index if I add another column to the index, assuming unique indexes are better than non-unique ones.
If it's just so that you can make the index unique, I probably wouldn't bother.
And, what if that column also happens to be part of the clustered index for that the underlying table? Would that alter your recommendation?
No, not really. If the index unique you should mark it as unique, don't go adding columns just to make it unique unless it also lets more queries use the index or otherwise enhances performance of something.
Gail Shaw Microsoft Certified Master: SQL Server 2008, MVP SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
We walk in the dark places no others will enter We stand on the bridge and no one may pass
|
|
|
|
|
SSC-Dedicated
           
Group: General Forum Members
Last Login: Today @ 2:26 PM
Points: 37,669,
Visits: 29,922
|
|
Cliff Jones (11/18/2009) The Tuning Adviser often recommends that a column which is also a part of the Clustered index be added as an included column. I do not do this since I assume that it is included in the index anyway. Would including such a column make the index larger for no apparent gain?
Depends where it's suggesting that the column be added. Sure, the clustering key will be there (though whether or not it can be used for seeks depends on a property of the index, specifically unique) but, as far as I know it's the last column. If the recommendation has the clustering key earlier in the index key, then it may be necessary. If it's just specified as an include it may be unnecessary.
That said, the clustering key isn't going to be there twice. If you explicitly define it as part of the index key, SQL's not going to add it again.
Gail Shaw Microsoft Certified Master: SQL Server 2008, MVP SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
We walk in the dark places no others will enter We stand on the bridge and no one may pass
|
|
|
|