Hacker News new | ask | show | jobs
by getmeinrn 1057 days ago
I was going to post about "use a UUID", but I was surprised to learn that no UUID uses both timestamp + a random component. You can either get fully random with UUID4, or have a time + MAC based UUID with UUID1. Strange, I would have thought there would exist a UUID that uses time + random to minimize collisions like described in the post.
6 comments

I believe the proposed UUIDv7 standard uses this.

https://datatracker.ietf.org/doc/html/draft-peabody-dispatch...

It's a draft but there's a lot of implementations out there.

ULID (and I think UUIDv7 draft) has millisecond timestamp + 80b randomness.
the new UUIDv6, 7 and 8 work the way you deacribe.
Only v6 and v7, v8 is "whatever you want".
That's not much of a standard.
From my reading, it's standardized because it has a version number embedded, so it won't get confused with other uuids.

Probably a good idea to have somewhere to silo bespoke implementations. Just gotta hope they end up being unique.

It's not uncommon to provide a way how to do it in standards because it will happen whether you want it or not. See e.g. HTTP headers starting with X- or MIME types in application/vnd.
Ksuid may be what you want. Pretty much time sortable uuid.

Go implementation: https://github.com/segmentio/ksuid

someone else in the thread mentioned UUIDv7
Can't find much info about it but is this UUID v7?