Hacker News new | ask | show | jobs
by zzzcpan 2952 days ago
> One advantage of using an incrementing integer is that rows will be ordered on disk based on when they were created

If each identifier starts with a logical time, say lamport timestamp, you can still get the same ordering effect without incrementing integers in a centralized place somewhere.

2 comments

I've written my own UUID generation function which uses the current timestamp with microsecond precision for the first 64 bits and a random value for the last 64 bits. So far it's been a great success.

Collisions are extremely unlikely unless you have Google scale and generated UUIDs are mostly ordered.

I've also done this at a medium ish scale. We had to be careful with how the uuids were generated, though. Specifically which portion of the bytes contained the timestamp (and in what order) since different databases store uuids differently.
Have used this to great results in postgres, mysql, redis, etc.