News for hackers. Stuff that matters.
Re:Moving Away from UUIDs by throwawaymaths on Monday November 21, 2022 @07:48PM (#33700367)
Also most well-designed systems only use the UUID as the representation format and use raw bits in performance-critical parts.
Re:Moving Away from UUIDs by lolinder on Monday November 21, 2022 @09:25PM (#33700994)
The raw bits are the UUID, the hex string is just a human-readable representation that also plays nicely with JSON.
Re:Moving Away from UUIDs by throwawaymaths on Monday November 21, 2022 @10:47PM (#33701564)
Tell that to Django (well 5 years ago anyways iirc, don't know what it does now). Pretty sure it used to store uuids as strings columns in your sql.
Re:Moving Away from UUIDs by lolinder on Monday November 21, 2022 @10:49PM (#33701582)
Yep, looks like it does the right thing in PostgreSQL but not anywhere else [0].

https://docs.djangoproject.com/en/4.1/ref/models/fields/#uui...

Re:Moving Away from UUIDs by throwawaymaths on Monday November 21, 2022 @10:52PM (#33701604)
I feel like it did strings in postgres too, not too long ago and I had a <brain explode> moment when I worked on a codebase and had to figure out why queries were terrible
Re:Moving Away from UUIDs by lolinder on Monday November 21, 2022 @11:03PM (#33701706)
Supposedly the behavior hasn't changed since at least version 1.8:

https://docs.djangoproject.com/en/1.8/ref/models/fields/#uui...

It may not have worked correctly on your project for some reason?

Re:Moving Away from UUIDs by throwawaymaths on Tuesday November 22, 2022 @12:20AM (#33702301)
Actually now that I remember we were using MySQL and I was pushing for migrating to postgres partially for this reason, sorry it was a long time ago in startup time
Re:Moving Away from UUIDs by fsloth on Tuesday November 22, 2022 @12:46AM (#33702479)
It’s a 128 bit integer - the serialization format does not change the fact.
Re:Moving Away from UUIDs by halhen on Tuesday November 22, 2022 @04:34AM (#33703833)
Or to PowerBI, which will any UUID to a string even in joins. That cast + string comparisons + killing of indexes is not conducive to performant queries...
Re:Moving Away from UUIDs by mort96 on Tuesday November 22, 2022 @07:51AM (#33705197)
I suppose Django wouldn't consider the speed gains of using raw integers in the database worth the hassle of dealing with binary data when you have to manually deal with the database somehow. I usually use string columns for UUIDs myself for the same reason.

It's also not given that it'll be a performance benefit, you probably receive UUIDs as strings from some client and probably want to return UUIDs as strings to the client, and that conversion isn't free.