Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««12345»»»

Introduction to Indexes: Part 3 – The nonclustered index Expand / Collapse
Author
Message
Posted Wednesday, November 18, 2009 12:37 PM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Yesterday @ 2:01 PM
Points: 40,390, Visits: 36,823
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

Post #821109
Posted Wednesday, November 18, 2009 1:39 PM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC 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?
Post #821160
Posted Wednesday, November 18, 2009 2:12 PM
Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Monday, November 10, 2014 12:05 PM
Points: 3,969, Visits: 3,648
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?
Post #821188
Posted Wednesday, November 18, 2009 2:53 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum 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
Post #821221
Posted Wednesday, November 18, 2009 3:19 PM


SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Saturday, November 8, 2014 4:49 AM
Points: 28, Visits: 182
Great read! Well written and informative.
Post #821241
Posted Wednesday, November 18, 2009 3:44 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Tuesday, November 18, 2014 2:25 PM
Points: 188, Visits: 1,567
Thanks for this series, Gail. I have really enjoyed reading it and found it very informative.

Cheers!


Nicole Bowman

Nothing is forever.
Post #821259
Posted Wednesday, November 18, 2009 4:44 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum 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
Post #821288
Posted Wednesday, November 18, 2009 7:09 PM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 8:55 AM
Points: 10,340, Visits: 13,340
j_braclin (11/18/2009)
i dunno. This kind of confused me.


Well then ask some questions. What are you confused about? I'm sure Gail, the author, will try to clarify, and I'll help where I can as well.




Jack Corbett

Applications Developer

Don't let the good be the enemy of the best. -- Paul Fleming

Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
How to Post Performance Problems
Crosstabs and Pivots or How to turn rows into columns Part 1
Crosstabs and Pivots or How to turn rows into columns Part 2
Post #821324
Posted Thursday, November 19, 2009 3:03 AM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Yesterday @ 2:01 PM
Points: 40,390, Visits: 36,823
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

Post #821433
Posted Thursday, November 19, 2009 3:10 AM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Yesterday @ 2:01 PM
Points: 40,390, Visits: 36,823
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

Post #821440
« Prev Topic | Next Topic »

Add to briefcase ««12345»»»

Permissions Expand / Collapse