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»»»

How many rows in a table before using a clustered index? Expand / Collapse
Author
Message
Posted Friday, November 2, 2012 5:57 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Wednesday, October 1, 2014 4:34 AM
Points: 32, Visits: 218
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!



Post #1380302
Posted Friday, November 2, 2012 6:55 AM


Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Thursday, August 1, 2013 10:17 AM
Points: 323, Visits: 984
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/


-----------------------------------------------------------------------------
संकेत कोकणे
Post #1380335
Posted Friday, November 2, 2012 7:06 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Wednesday, October 1, 2014 4:34 AM
Points: 32, Visits: 218
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?



Post #1380339
Posted Friday, November 2, 2012 7:07 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: Today @ 5:50 AM
Points: 40,209, Visits: 36,618
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 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 #1380340
Posted Friday, November 2, 2012 7:07 AM


SSCarpal Tunnel

SSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal Tunnel

Group: General Forum Members
Last Login: Yesterday @ 10:32 AM
Points: 4,023, Visits: 5,323
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”
Post #1380341
Posted Friday, November 2, 2012 7:09 AM


Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Friday, August 1, 2014 12:17 PM
Points: 336, Visits: 389
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/
Post #1380342
Posted Friday, November 2, 2012 7:15 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: Today @ 5:50 AM
Points: 40,209, Visits: 36,618
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 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 #1380346
Posted Friday, November 2, 2012 7:18 AM


Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Thursday, August 1, 2013 10:17 AM
Points: 323, Visits: 984
Me too !!

-----------------------------------------------------------------------------
संकेत कोकणे
Post #1380347
Posted Friday, November 2, 2012 7:22 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Friday, June 27, 2014 12:43 PM
Points: 13,872, Visits: 9,596
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
Post #1380350
Posted Friday, November 2, 2012 9:48 AM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: Administrators
Last Login: Wednesday, October 22, 2014 12:34 PM
Points: 31,181, Visits: 15,626
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
Post #1380471
« Prev Topic | Next Topic »

Add to briefcase 12345»»»

Permissions Expand / Collapse