UUIDv7 doesn't have the properties you think it does

(alexsci.com)

33 points | by ibobev 1 hour ago

11 comments

  • hackingonempty 19 minutes ago
    > If you need to list things ordered by creation time very often, it’s useful if the primary index gives that behavior, removing the need for another index.

    I thought the main reason UUIDv7 was created with a time component is to keep temporally related rows together in the index pages. Randomly distributed row ids seem OK until the entire index no longer fits in RAM.

  • skrebbel 14 minutes ago
    I feel like this article way downplays the entire point of UUIDv7s, which is that it lets you sort (and store!) your data kinda sorta by creation time, no overlap ever. That's great for cursors, for streaming data, for twitter clones, for chat messages, for player moves, and so on and so forth. Nearly everything that's vaguely realtimey that you might like to both persist and broadcast live to other clients, and displayed in a stable & reasonable order, benefits from a property like this.

    In fairness, he does mention this, but squeezes it into a single sentence near the end. But eg the fact that you can't reliably extract the precise timestamp from the UUIDv7 is a feature, not a bug. It's either that or collisions and you don't want the collisions.

  • 0x20cowboy 11 minutes ago
    As others have said, I don’t think the time was meant to be something you relied on for the object time, but more the help with indexing and sharding.
  • sedatk 33 minutes ago
    You probably don't need a UUID: https://ssg.dev/you-probably-dont-need-a-uuid/
    • kune 6 minutes ago
      I support this. I wrote a Sqlite plugin for KSUIDs, but at the end I never used them, since all I do can be handled by integer primary keys, which sqlite maps to the rowid automatically. Autoincrement is only required, if you want to prevent the reuse of ids in deleted rows.
  • jefecoon 30 minutes ago
    Great article.

    I assume I'm oblivious and naive, but it seems theoretically possible these issues could -- theoretically -- result in TOCTOU or similar issues.

    Any thoughts about relying on:

    - central time service, with message-queue of inbound requests, resulting in correctly timed + sequenced events [ albeit with hopefully small lag tradeoffs ]?

    - know of any databases that implement this type of logic around their own minting of time-stamped UUIDs?

    Prior efforts implementing event-driven backend service with UUID7s minted in client-code seemed perfectly fine at low usage/scale. However, as clients + usage + event-volume scaled, team became more curious about time/timestamp/related issues, and any minting client-side quickly fell out of favor.

    Any insights greatly appreciated -- thanks

    [ edited b/c i don't know how to format... ]

  • phoronixrly 23 minutes ago
    Wow... That is some nitpicking... The major issue these UUIDs solve for me is the fact that using a random UUID as a primary key of a relational database leads to horrible performance...

    It has never crossed my mind to decode the timestamp from them so I save myself a 12-byte column, neither has it crossed my mind to have them monotonic in a distributed system...

  • saagarjha 27 minutes ago
    Just use UUIDs as they were meant to be used, as a random identifier. Don't shove random other junk into it!
  • ForHackernews 14 minutes ago
    Most (all?) of these are also true of UUIDv1. Devs in 2026 should be well versed in using UUIDv4 if they really truly can never leak anything.
  • pphysch 39 minutes ago
    > My mental model for UUIDv7 is that it’s a mash-up of a bunch of different ideas which implementations are free to choose as they see fit. There’s a wide variance of properties that UUIDv7 implementations can provide, with varying degrees of certainty they can successfully provide those properties.

    I think this is good. A proper UUID that has specific significant bits dedicated to (approximately) monotonic values is useful. I don't want it over-specified beyond that, and I don't want to just use UUIDv8.

  • doormatt 36 minutes ago
    [dead]
  • Vaushite 43 minutes ago
    [dead]