Tags

,


This has always been the hot topic between the developers and database designers. Both implementations have their advantages and disadvantages. At the outset, I shall mention that the answer to this debate is: IT DEPENDS!

Today I will compare GUID and INT from the database designing perspective:
Basically we use GUID or Identity to auto-generate key values for out tables.

The main issue with GUID is its very large (16 Bytes). And as GUID is basically for the purpose of creating Primary Keys to ensure uniqueness of rows. So by default Clustered Index is create on GUID column and generally we want to keep the key column for Clustered Index as narrow as possible for JOINS, INDEXES and other Conditions. Indexes that are built using uniqueidentifier keys might be relatively slower than indexes using an int key.Clustered index on GUID also hurt performance for non-clustered index as Non Clustered index uses clustered key as page pointer on leaf-level pages. When GUID is used in the tables then they are more fragmented and further degrades the performance.
Some argument in favor of GUID and its mainly to maintain uniqueness in merge replication scenario or data warehousing scenario where data will be migrated from multiple servers and having single identity (INT) column will cause duplication. We can also use it in the disconnected architecture.

Please add any comments if I have missed any points to highlight regarding the two data types.

Till then Keep Learning!!

Cheers
Subhro Saha

Advertisements