News for hackers. Stuff that matters.
Re: by marcosdumay on Friday February 09, 2024 @10:22PM (#39323264)
Serial integers always work better than any uuid as PKs, but the thing with uuid4 is that it disrupts any kind of index or physical ordering you decide to put on your data.

Uuids are really for external communication, not in-system organization.

Re: by dalyons on Friday February 09, 2024 @10:54PM (#39323414)
FWIW this isn’t true anymore with newer uuid schemes like v7 that are roughly time sortable.
Re: by ildjarn on Saturday February 10, 2024 @07:42AM (#39325764)
Serial index forces a synchronisation point on every entity that can create records. If this is only ever a single database that’s fine but plenty of apps can’t scale this way.
Re: by marcosdumay on Saturday February 10, 2024 @09:50AM (#39326513)
They don't. Clustered databases deal with parallel generation of them just fine.

They require periodic synchronization. What isn't a big deal at all and is required by many other database features.

Re: by sgarland on Saturday February 10, 2024 @12:25PM (#39328150)
If you have a sharded DB, each instance can get its own range of ints, which are periodically refreshed.

PlanetScale uses int PKs [0], and they seem to have scaled just fine.

[0]: https://github.com/planetscale/discussion/discussions/366