dcsimg
Login | Register   
LinkedIn
Google+
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

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


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

WEBINAR:

On-Demand

Building the Right Environment to Support AI, Machine Learning and Deep Learning


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
Thanks for your registration, follow us on our social networks to keep up-to-date