Patrick
Patrick

Reputation: 5592

SQL Server 2008 uniqueidentifier vs. Binary performance

In a logging perspective with millions of rows. What is the preferred way?

Do you store the Guid as a UniqueIdentifier or in Binary? Which is faster for searching?

The C# part of generating the values is not an issue here.

Upvotes: 0

Views: 1511

Answers (1)

gbn
gbn

Reputation: 432200

A GUID is stored as binary but there are rules attached when comparing and sorting that are different to straight binary. See How is a guid actually stored and sorted/compared in SQL Server? for more

Whatever you choose, don't use a GUID a a clustered index. For why, see What are the reasons *not* to use a GUID for a primary key? as one example.

Upvotes: 4

Related Questions