Datatype: uniqueidentifier or bigint as primarykey?

Uniqueidentifier or bigint as primarykey? Which is better to use as a primary key?

Using uniqueidentifier you will be given a global uniqueidentifier
but this also means the value will be very large! larger than bigint!
16 bytes vs 4 bytes!!!

is it really important?
KhouAsked:
Who is Participating?
 
SujithConnect With a Mentor Data ArchitectCommented:
I dont think it makes any considerable difference, as long as you dont have a composite primary key.
0
 
Cedric_DConnect With a Mentor Commented:
From my point of view, it makes difference for  large tables.
Redundant 12 bytes could be at cost, because as PK it will involved in all seek operations.

Another reason: you cannot make guid autoincrement (by IDENTITY(1,1)).

The only huge benefit of guid is really multy-server environment, to provide uniqueness.




0
 
dportasConnect With a Mentor Commented:
Depends what you are going to use it for. You haven't given us much clue because "primary key" actually says very little about how it will be used. Do you mean that you intend to use it only as a surrogate key?
0
 
KhouAuthor Commented:
@dportas
" Do you mean that you intend to use it only as a surrogate key?"

Yes,

At the end of the day, I decided to Unquieidentifier , with newsequecialid().

Reason: GUID for replication, newsequeicailid() for performance.
still not as fast as int, but will do.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.