4 ms·
They're snowflake IDs, not exactly sequential. Timestamp bits, shifted all the way left Data center id shifted left Server id shifted left Increment this milli
by RhodesianHunter 8y ago
They're snowflake IDs, not exactly sequential.
Timestamp bits, shifted all the way left
Data center id shifted left
Server id shifted left
Increment this millisecond
Since the left bits are the timestamp, they are date/time sortable and a much more useful index/primary key/whatever than a UUID.
- thinkloop 8y agoYou can prefix the uuid with a timestamp for the same effect without leakage. There are chronological uuid projects: https://github.com/uucid-project/spec https://github.com/uucid-project/spec
- RhodesianHunter 8y agoYou can, but why would you? You're advocating slapping lipstick on a pig not really engineered for this use case vs. using something that was designed for it. UInt64's are going to be all around more efficient.
- thinkloop 8y agoYou wouldn't, just showing that it's an easy problem to solve.