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


Unique Identifier as Clustered index


Unique Identifier as Clustered index

Author
Message
Wilfred van Dijk
Wilfred van Dijk
SSCommitted
SSCommitted (2K reputation)SSCommitted (2K reputation)SSCommitted (2K reputation)SSCommitted (2K reputation)SSCommitted (2K reputation)SSCommitted (2K reputation)SSCommitted (2K reputation)SSCommitted (2K reputation)

Group: General Forum Members
Points: 1960 Visits: 1363
Comments posted to this topic are about the item Unique Identifier as Clustered index

Wilfred
The best things in life are the simple things
Sergiy
Sergiy
SSCoach
SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)

Group: General Forum Members
Points: 18573 Visits: 12317
I believe "indexes with only one column" does not reveal all the indexes we need to see.

Clustered indexes with 1st column of uniqueidentifier type are as bad, probably even worse.

Following version of the script reveals all "bad" clustered indexes:

select  object_name(i.object_id) [object name], i.name [index name],  c.name [UID column name]
from sys.indexes i
inner join sys.index_columns ic ON i.object_id = ic.object_id and i.index_id = ic.index_id AND index_column_id = 1
inner join sys.columns c on ic.object_id = c.object_id and ic.column_id = c.column_id
inner join sys.types t on c.user_type_id = t.user_type_id AND t.name = N'uniqueidentifier'
where i.object_id > 1000 -- no system objects
and i.type = 1 -- clustered
order by 1,2;


Wilfred van Dijk
Wilfred van Dijk
SSCommitted
SSCommitted (2K reputation)SSCommitted (2K reputation)SSCommitted (2K reputation)SSCommitted (2K reputation)SSCommitted (2K reputation)SSCommitted (2K reputation)SSCommitted (2K reputation)SSCommitted (2K reputation)

Group: General Forum Members
Points: 1960 Visits: 1363
Good addition, thanks for your reply!

Wilfred
The best things in life are the simple things
Trevor Ball
Trevor Ball
SSCommitted
SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)

Group: General Forum Members
Points: 1567 Visits: 222
I'd like to hear an explanation of what the problem is with a clustered index on a uniqueidentifier. Is it just the fact that as the table grows, the index will need to be reorganized often, or is there a more fundamental problem with width or with the datatype itself?

I have some tables with clustered indexes on uniqueidentifiers, but they are relatively small lookup tables that rarely change, so I haven't been concerned about them up to now; are you saying I should be?
Wilfred van Dijk
Wilfred van Dijk
SSCommitted
SSCommitted (2K reputation)SSCommitted (2K reputation)SSCommitted (2K reputation)SSCommitted (2K reputation)SSCommitted (2K reputation)SSCommitted (2K reputation)SSCommitted (2K reputation)SSCommitted (2K reputation)

Group: General Forum Members
Points: 1960 Visits: 1363
I advise you to have a look at http://www.sqlskills.com, which contains some excellent articles about index management.

A direct answer to your question: http://www.sqlskills.com/blogs/kimberly/ever-increasing-clustering-key-the-clustered-index-debate-again/

Wilfred
The best things in life are the simple things
Iwas Bornready
Iwas Bornready
SSCoach
SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)

Group: General Forum Members
Points: 18892 Visits: 885
Thanks for the script.
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