Login | Register   
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: SQL Server
Expertise: Beginner
Apr 24, 2000

uniqueidentifier vs. int

Question:
If I have the option of using the uniqueidentifier or int data type for a primary key, will choosing the uniqueidentifier mean a significant performance degradation?

Answer:
The uniqueidentifier data type is a 16-byte binary, and its only real advantage is that it provides a globally unique identification (GUID) number across all networked computers. GUIDs have a number of disadvantages though. For example, the numbers are long (36 chars translated into a string) and hard to work with. When you're checking data it's much harder to remember 6F9619FF-8B86-D011-B42D-00C04FC964FF than a number like 120300.

In addition, a uniqueidentifier value is 16 bytes long while the int data type is only four bytes, so it will affect performance on indexes and foreign keys. Unless you require a GUID, a primary key column of datatype int with IDENTITY is a good choice.

DevX Pro
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap