UUID versus auto increment number for primary key?

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.

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.

Andrey and Mjg both had good points, but I would add a related performance issue that is significant. With the decoupling of database and key generation also allows applications that have complex relationships between objects to create them all with the keys in place, so that bulk inserts are possible. In the case of auto-increment, all of the objects that own relationships (ie the tables with foreign keys) have to wait for the other side of the relationship (ie the table the foreign key comes from) to save, query the assigned ids, and then individually update the records former records.

On another note, we're considering using UUID version 2 in an application for accountability--it incorporates the exact time (in microseconds) and the MAC address of the machine creating it. – Bryan Agee May 31 at 17:48.

The main pro that you can generate them independently. Con is that it is larger.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions