Most documentation says to put the clustered index on the Primark Key....

I asked  a question last week.. but I am not sure I successfully put my idea across(http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SQL-Server-2005/Q_26831283.html)

I would like to re introduce the question, but this time I have added more sources.

Most documentation says to put the clustered index on the Primark Key....

However, after reading SQL Server 2008 Query Performance Tuning Distilled (Apress) page 118 it suggests putting a unique non-clustered index on the Primary Key.

This idea is also mentioned in SQL Server 2005 Performance Tuning (Wrox) page 234 and Inside Microsoft SQL Server 2005 Query Tuning and Optimization (Microsoft) 232.

Does anybody have any comments on not using the clustered index on an IDENTITY(1,1) INT Primary Key column?

I am using sql 2005/2008..... It would be also interesting if a different approach exists for other datase engines?

Here are a number of links which discuss the idea.
http://www.mssqlcity.com/Tips/tipInd.htm - See section beginning 'Avoid creating a clustered index based on an incrementing key'.

http://www.devx.com/tips/Tip/5648

http://books.google.co.uk/books?id=CD6Y4wAdQpwC&printsec=frontcover&dq=sql+server+2008+query+performance+tuning+distilled&hl=en&ei=uD5gTdnJE4yb4Aau-LDFCQ&sa=X&oi=book_result&ct=result&resnum=1&ved=0CDsQ6AEwAA#v=onepage&q&f=false

http://bytes.com/topic/sql-server/answers/81459-why-cluster-primary-key
http://social.msdn.microsoft.com/Forums/en-US/sqldatabaseengine/thread/cf9121b2-38e0-4735-b765-4eab91bb443b/

http://stackoverflow.com/questions/581505/is-primary-key-always-clustered

http://www.sqlservercentral.com/Forums/Topic1048687-391-1.aspx

http://www.sqldev.org/transactsql/which-index-is-better-64091.shtml
Mr_ShawAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Guy Hengel [angelIII / a3]Billing EngineerCommented:
well, there are 2 things:
* if you have a table where only the primary key is indexed, it shall be a clustered index
* if you have a table where other indexes exist besides the primary key, it shall not be the primary key that is the clustered index.

the reasoning behind is this:
* a table without a clustered index is managed like a heap, which will result in eventually lots of space wasted if there is lots of updates and deletes on the table
* clustered indexes are best to support range queries (BETWEEN, >= , < etc ... )

short conclusion:
* if you have a very small table, or a table that changes very rarely, you would not really need a clustered index, but it won't hurt neither
* if you have a large table, or a table with lots of changes (update/delete), a clustered index shall exist on the table, but usually, it won't be the primary key unless that is the only index on the table
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Mr_ShawAuthor Commented:
If my Primary Key is on a column with an INT Identity Datatype will this ensure that row INSERTs are added in order to the data pages....
0
Mr_ShawAuthor Commented:
It seems that most of the DB world put clustered index on the Primary Key...
0
Mr_ShawAuthor Commented:
thanks..
0
dportasCommented:
Most tables will benefit from a clustered index but it doesn't necessarily make sense to say that a primary key should be the clustered index. It depends on what the primary key is and how it is used.

Just saying that something is the primary key doesn't really tell us enough to determine whether it should be clustered or not. For example a uniqueidentifier column generally is not a good choice for a clustered index key, whether the uniqueidentifier is a primary key or not.

Choosing keys and indexes are separate concerns. Don't assume that one must follow from the other.

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2005

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.