SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


How many rows in a table before using a clustered index?


How many rows in a table before using a clustered index?

Author
Message
Stueyd
Stueyd
SSC-Enthusiastic
SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)

Group: General Forum Members
Points: 143 Visits: 285
Hi All,

I've just inherited a database and whilst doing a health check discovered about 300 tables that don't have clustered indexes.
Now anything with zero rows I will ignore and anything with 20,000 rows and above I will immediately investigate to see about slapping on a clustered index.
What about the others?
Is there a "rule of thumb" ? Eg: Any table with more than 1,000 rows could benefit from a clustered index?
What's the tipping point where there's so few rows it's not worth it?

Cheers!



sanket kokane
sanket kokane
SSC-Addicted
SSC-Addicted (475 reputation)SSC-Addicted (475 reputation)SSC-Addicted (475 reputation)SSC-Addicted (475 reputation)SSC-Addicted (475 reputation)SSC-Addicted (475 reputation)SSC-Addicted (475 reputation)SSC-Addicted (475 reputation)

Group: General Forum Members
Points: 475 Visits: 1022
you should have clustered index on every table .
that is what they called as best practice.

data is not organized properly in heap tables (tables without clustered index)



http://msdn.microsoft.com/en-us/library/hh213609.aspx
http://technet.microsoft.com/en-us/library/cc917672.aspx
http://www.simple-talk.com/blogs/2007/12/17/should-you-always-use-a-clustered-index/

-----------------------------------------------------------------------------
संकेत कोकणे
Stueyd
Stueyd
SSC-Enthusiastic
SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)SSC-Enthusiastic (143 reputation)

Group: General Forum Members
Points: 143 Visits: 285
Thanks for the textbook answer. Not!
Yeah, that's what it says "in the manual", but the reality is that there is a point below which a Clustered Index is more of an overhead than a help.
Anyone got a rough rule of thumb for what that point is?
1,000 rows? 5,000 rows?



GilaMonster
GilaMonster
SSC Guru
SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)

Group: General Forum Members
Points: 86897 Visits: 45266
Stueyd (11/2/2012)
What's the tipping point where there's so few rows it's not worth it?


0.

Every table should have a clustered index unless you have a good reason otherwise (low row count is not a good reason)

but the reality is that there is a point below which a Clustered Index is more of an overhead than a help.


No, there isn't.

Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
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


Stewart "Arturius" Campbell
Stewart "Arturius" Campbell
SSCrazy Eights
SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)SSCrazy Eights (8.8K reputation)

Group: General Forum Members
Points: 8839 Visits: 7281
Having a clustered index on every table is almost always a good idea.
However, using a clustered index just for the sake of having a clustered index on a table is not.
Clustered indexes are best suited for those columns most frequently used in range-based searches.

____________________________________________
Space, the final frontier? not any more...
All limits henceforth are self-imposed.
“libera tute vulgaris ex”
NuNn DaddY
NuNn DaddY
Old Hand
Old Hand (393 reputation)Old Hand (393 reputation)Old Hand (393 reputation)Old Hand (393 reputation)Old Hand (393 reputation)Old Hand (393 reputation)Old Hand (393 reputation)Old Hand (393 reputation)

Group: General Forum Members
Points: 393 Visits: 490
Here is a link to the MSDN for Clustered Index Design Specifications which may help you better understand what columns you should use for your clustered index.

http://msdn.microsoft.com/en-us/library/ms190639%28v=sql.105%29.aspx

Also, you may want to consider taking a look at the "Stairway to SQL Server Indexes" which explains both clustered and nonclustered indexes

http://www.sqlservercentral.com/stairway/72399/
GilaMonster
GilaMonster
SSC Guru
SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)

Group: General Forum Members
Points: 86897 Visits: 45266
Stewart "Arturius" Campbell (11/2/2012)
Clustered indexes are best suited for those columns most frequently used in range-based searches.


I would tend to disagree with that, but that's just me.

Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
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


sanket kokane
sanket kokane
SSC-Addicted
SSC-Addicted (475 reputation)SSC-Addicted (475 reputation)SSC-Addicted (475 reputation)SSC-Addicted (475 reputation)SSC-Addicted (475 reputation)SSC-Addicted (475 reputation)SSC-Addicted (475 reputation)SSC-Addicted (475 reputation)

Group: General Forum Members
Points: 475 Visits: 1022
Me too !!

-----------------------------------------------------------------------------
संकेत कोकणे
GSquared
GSquared
SSC-Insane
SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)

Group: General Forum Members
Points: 23369 Visits: 9730
GilaMonster (11/2/2012)
Stewart "Arturius" Campbell (11/2/2012)
Clustered indexes are best suited for those columns most frequently used in range-based searches.


I would tend to disagree with that, but that's just me.


Not just you.

- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread

"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
Steve Jones
Steve Jones
SSC Guru
SSC Guru (62K reputation)SSC Guru (62K reputation)SSC Guru (62K reputation)SSC Guru (62K reputation)SSC Guru (62K reputation)SSC Guru (62K reputation)SSC Guru (62K reputation)SSC Guru (62K reputation)

Group: Administrators
Points: 62130 Visits: 19102
I would always have a clustered index. Unless I had a really good reason not to have one. I'd read some of the articles mentioned, especially any by Gail on indexing to help decide what column(s) to use in the index.

Other indexes may or may not help, depending on the size of the table.

Follow me on Twitter: @way0utwest
Forum Etiquette: How to post data/code on a forum to get the best help
My Blog: www.voiceofthedba.com
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search