Our data resides in a SQL Server 2008 database, there will be a lot queries and joinings between tables. We have this argument inside the team, some are arguing use of integ
A 128-bit GUID (uniqueidentifier
) key is of course 4x larger than a 32-bit int
key. However, there are a few key advantages:
SELECT
from the primary key based on a date/time range if you want with a few fancy CAST()
calls.SELECT scope_identity()
to get the primary key after an insert.bigint
(64 bits) instead of int
. Once you do that, uniqueidentifier
is only twice as big as a bigint
.In the end, squeezing out some small performance advantage by using integers may not be worth losing the advantages of a GUID. Test it empirically and decide for yourself.
Personally, I still use both, depending on the situation, but the deciding factor has never really come down to performance in my case.