Alex Rivera | Logout

UUID versus auto increment number for primary key

Asked 2011-03-01T19:36:37.400
16

Why should I choose UUID over an auto increment number for my entity's primary key? What are the pros and cons?

Edit
Report

1 Answer

9

UUIDs are globally unique, and can be generated in parallel without communication between clustered DB servers. So "Object IDs are more synergistic with sharding and distribution.". UUIDs are typically stored in 128 bits.

Auto-incremented integers are more user-friendly (well, shorter and more memorable anyway), and automatically allow sorting by insertion-order. Integers are typically stored in 32 or 64 bits.

answered 2011-03-01T19:38:58.087

Your Answer