SQL Clone
SQLServerCentral is supported by Redgate
Log in  ::  Register  ::  Not logged in

Are There That Many GUIDs?

By Steve Jones,

This editorial was originally published on Oct 12, 2010. It is being re-run as Steve is away on vacation.

Do a lot of people actually use GUIDs as Primary Keys? I haven't used them much, and I would have thought that more people chose identity keys. It seems that most of the demos and examples I see from bloggers and speakers are constantly using identities.

However an informal survey from Peter Bromberg showed that four times as many people actually had GUIDs as their primary keys. The blog actually says that GUIDs are not a good choice, but I'm not sure I agree with that. You can use sequential GUIDs, and you can avoid making them the clustered key, so I think they can work as well as anything.

There's nothing inherently wrong with GUIDs, and they should be unique across all of your rows. There have been some reported cases of duplicates, but for most practical purposes, especially in database work, you ought to be able to count on a GUID as unique. They even have the nice capability of being generated by clients, removing the need for an extra round trip when a client needs to insert multiple rows.

I typically don't use them because they're long, hard to remember and type, and hard to view on the screen. I can't easily compare rows in multiple tables, and it's easier for me to work with integers.  I don't recommend them, but if you are going to use them, be sure you understand the pros and cons, and use them appropriately.

Total article views: 585 | Views in the last 30 days: 2
Related Articles

Most Interesting Peopleā€¦

Here are the most interesting people I met at PASS Summit 2012   Mickey Stuewe (sqlmickey) Neil H...


Tuning People?

Database people are used to changing the hardware of the server on which a problem database resides...


Actual Query Plan - Actual Row Count massively exceeds Est Row Count

Est rows < 1m Actual rows ~1500m


Sales People & Commission

I saw this post by Neil Davidson about sales people being different that discusses how sales people ...


Max Actual datalength

This script returns the defined rowlength and the actual datalength for the longest row in a table. ...