News for hackers. Stuff that matters.
Re:Show HN: 128-bit, roughly-ordered, URL-safe UUIDs by solicode on Friday January 22, 2021 @07:40AM (#25871175)
I like ordered UUIDs, but if you care about 100% strict and accurate ordering you need to be careful about generating them in app code vs. on the DB side. With the former + using multiple app servers, server clock drift can become an issue. Which is why I still generate my ordered UUIDs on my Postgres server. It means writing some funky PL/pgSQL (or however you decide to do it... I think you can run Python too), but it gets the job done.

I wish ordered UUIDs were built-in to more DBs natively. I remember seeing UUIDv6 being proposed, but I don't know if/when that will be standardised.

Re:Show HN: 128-bit, roughly-ordered, URL-safe UUIDs by httgp on Friday January 22, 2021 @08:03AM (#25871302)
How does one generate ordered UUIDs right on the PostgreSQL server?
Re:Show HN: 128-bit, roughly-ordered, URL-safe UUIDs by Tostino on Friday January 22, 2021 @12:45PM (#25874050)
Use this: https://github.com/tvondra/sequential-uuids

If you cannot install extensions, I just wrote a PL/PGSQL implementation for the time-based generator I could share.

Re:Show HN: 128-bit, roughly-ordered, URL-safe UUIDs by Sytten on Friday January 22, 2021 @02:29PM (#25875262)
Please do I have been looking for that. Posting it in the repo would help a few people k am guessing.
Re:Show HN: 128-bit, roughly-ordered, URL-safe UUIDs by Tostino on Friday January 22, 2021 @03:11PM (#25875780)
Re:Show HN: 128-bit, roughly-ordered, URL-safe UUIDs by solicode on Friday January 22, 2021 @08:17AM (#25871389)
There's probably a nicer way (or more performant at least), but I created a function that uses the built-in `uuid_generate_v1mc` and then reverse the order of the time component so that high values come first.