sql

2024-05-19T21:47:17.096229Z

Asking for advice. I found ULID https://github.com/ulid/spec It's kind of compatible with postgres uuid. I'm using de.huxhorn.sulky/de.huxhorn.sulky.ulid {:mvn/version "8.3.0"} from https://github.com/huxi/sulky/tree/master/sulky-ulid Made tiny a wrapper: https://gist.github.com/geraldodev/e3eaef6c4811649bdf05a8775632b5df Configured custom reader tag ulid/id Got to the point that I'm deciding if it's worth to instrument next.jdbc to read uuid from postgres database as ULID or generate an java.util/UUID from an ULID (which is going to be sortable) . Which do you think I should go ? Can you share your experiences with ULID and next.jdbc ?

dharrigan 2024-05-20T11:32:40.872249Z

I really look forward to when PostgreSQL supports type-7 UUIDs. In the meantime, I've been exploring and playing with ULID for several solutions and they work great too! 🙂 It's all good!

➕ 1
curtis.summers 2024-05-20T15:04:45.684099Z

You can add uuid v7 and uuid v8 support to PG with these functions: https://gist.github.com/kjmph/5bd772b2c2df145aa645b837da7eca74

👍 2
p-himik 2024-05-19T21:53:44.473099Z

Note that there's also UUIDv6/v7 which, if all the components of your systems support it, might be a better fit.

2024-05-19T22:01:23.574409Z

@p-himik Why ? Can you explain ?

2024-05-19T22:04:36.216249Z

There were a number of schemes of simply lexigraphically sorted ids (flake ids, squuids, ulid, etc) but as of the last few years there are new uuid types intended to cover that case

2024-05-19T22:08:56.617899Z

v7 in particular is almost identical to what ulid proposed there, it just includes the uuid version field as well

👍 1
2024-05-19T22:09:47.386139Z

So the big difference just becomes uuids default to hex encoding

2024-05-19T22:13:39.220769Z

Ulid can be used to generate links. Postgres driver already reads uuid type into java.util.UUID so no need for translation.

2024-05-19T22:15:57.405519Z

That is just base32 encoding instead of hex