Reputation: 17293
If I needed to unqiuely identify rows in a T-SQL database table I would set them as:
[id] INT NOT NULL IDENTITY(1,1) PRIMARY KEY
But if I need ID to be unique among several databases (on different computers) I go with:
[uid] UNIQUEIDENTIFIER NOT NULL
and then set an index on that column:
CREATE INDEX index_name ON [TableName] ([uid]);
So I was wondering how much of a performance hit would the database take by changing INT to UNIQUEIDENTIFIER?
Upvotes: 0
Views: 2740
Reputation: 280252
GUID
is not the only option for surrogate values to be unique across databases. Two options come to mind immediately:
BIGINT
and set the identity seed on each database, starting with, say, 1000000000 on database A, 2000000000 on database B, etc. This supports many, many databases.In SQL Server 2012, you will be able to implement (2) much easier using SEQUENCE.
Upvotes: 5