Skip to main content
Known Participant
May 28, 2007
Question

UUID for Primary Key?

  • May 28, 2007
  • 11 replies
  • 2167 views
The fundamental question is:
Should I use UUID for primary keys in my database tables or should I just use the typical integer that is auto-incremented with every new row?

I'm trying to understand what the trade space is.

Thanks!
This topic has been closed for replies.

11 replies

May 29, 2007
UUID/guid versus integer (identity or otherwise) is a piece of database religion. There are many who have strong opinions on both sides of the argument. The main argument for ints against uuids is space and a couple of milliseconds. The main argument for uuids against ints is that it better satisfies the rule that there should be no "intelligence" in your primary key and that you are guaranteed that your pks from various tables won't collide if you need to merge disparate data. uuids also help protect against id probing from people trying to guess meaningful ids through a web interface.

My personal current preference is for uuids