Remix.run Logo
blopker 3 hours ago

UUIDs are way over used. There is almost always a better key to use, usually a bigint for databases. If you're making some kind of leaderless distributed data store, then maybe, but even then there are other ID sharding strategies I'd go for first depending on the constraints.

For a single database, bigints are smaller and faster, with less footguns.

UUIDs can be nice for an opaque public ID, however I'd still prefer something like a Sqid for space and usability.

Fabricio20 an hour ago | parent | next [-]

> bigints are smaller and faster, with less footguns

But be careful!! Javascript WILL interpret your bigints as Number() and round them down because they are too big without telling you!!!

Famously seen by every snowflake user that has interacted with Javascript, quite an annoying problem.

spiffytech 35 minutes ago | parent | next [-]

Fortunately we're seeing more JS DB libraries offering to read large numbers as the BigInt type.

paulddraper 18 minutes ago | parent | prev [-]

!!

Node.js drivers will correctly read int64 as string or bigint, not number.

E.g. pg for PostgreSQL

Maybe there’s a buggy driver but I don’t know it.

JamesSwift an hour ago | parent | prev | next [-]

UUIDs also have a nice benefit of it being impossible to query the wrong table with one if you mixup what an FK goes to

pyuser583 38 minutes ago | parent [-]

Yeah this is nice - also helps with grepping dump files.

bob1029 2 hours ago | parent | prev | next [-]

I am finding UUIDs help a lot if your primary schema consumer is an LLM.

Inappropriate aliasing of integer keys allows for silent errors in queries because it will actually return some result a lot of the time. A UUID is immune to this problem. The model recognizes its mistake a lot more reliably when previously non-empty tables start showing up empty after attempting a join.

crubier an hour ago | parent | prev | next [-]

No one ever got fired for using UUIDs

2 hours ago | parent | prev [-]
[deleted]