Cluster primary key in a unique identifier identifier column in SQL Server

If the identifier column in the table is a unique identifier (Guid), is there any point that creates the primary key clustered in the ID column?

Given that they are unique around the world, how will sorting work?

+3
sql-server uniqueidentifier primary-key
source share
4 answers

GUIDs, because they are terrible for performance, because they are actually random values ​​(this "breaks up" the cluster index), and they are terrible for indexes, since fewer entries fit into one page / degree (SQL Server terms). SQL Server 2005 introduces newsequentialid() , which helps solve the first problem.

+5
source share

I highly recommend using the Guid cluster key ... We had big performance issues on the SQL server due to such poor design a few years ago.

Also Check: Cluster Index Primary GUID Key Performance Improvement

+5
source share

Enabling a clustered index in a guid column is not such a good idea (unless you use consistent prompts).

The clustered index defines the physical order in which records are stored.
This means that if you put a clustered index on a column that will not grow sequentially, SQL Server will have some work to do, making sure the records are physically ordered correctly when inserting new records.

+3
source share

The idea of ​​having a sorted index is very good in itself, as the search becomes very efficient.

However, the problem is that in the case of the GUID, no one is looking for "WHERE GUID = xyz". So the whole concept is wasted. Therefore, I would rather have a clustered index in the column, which is most often used as SARG to improve query performance.

+1
source share

All Articles