--

UUIDs are far better than auto-incrementing IDs for most situations. Auto-incrementing IDs make it impossible to avoid accidental duplicates and they can't scale beyond one host because ensuring uniqueness requires central allocation which is a single point of failure.

Also, auto-incrementing IDs can't prevent duplicate entries because there can be situations where an HTTP request to create a record fails just after the record was inserted but just before the response is sent back... Then the user will see an error since the response won't reach them but if the user retries the failed operation, it will create a duplicate record in the database. With UUIDs, they can be created on the client side so operations are idempotent, the second insertion will fail with an appropriate warning message for the user "Record already exists."

--

--

Responses (1)