I have a junction table in my SQL Server 2005 database that consist of two columns:
-
object_id (uniqueidentifier)
-
property_id (integer)
These values together make a compound primary key.
What’s the best way to create this PK index for SELECT performance?
If the columns were two integers, I would just use a compound clustered index (the default). However, I’ve heard bad things about clustered indexes when uniqueidentifiers are involved.
Anyone have experience with this situation?
Yes, GUID’s are really bad for clustered indexes, since the GUIDs is by design very random and thus leads to massive fragmentation and thus performance problems.
See Kim Tripp’s blog – most notably “The CLustered Index Debate continues” and “GUIDs as PRIMARY and/or CLUSTERED key” – for a lot of valuable background info.
If you really need to have an index on these TWO columns, I’d suggest a non-clustered index – it can be a primary index – just better not a clustered index.
Marc