News for hackers. Stuff that matters.
Re:Moving Away from UUIDs by corytheboyd on Monday November 21, 2022 @06:22PM (#33699609)
Yeah I don't really get the point of this article, if you need random values of a specific size don't use uuid, it's literally specified to be one exact length and format.
Re:Moving Away from UUIDs by tejtm on Monday November 21, 2022 @06:39PM (#33699777)
one exact length and five "versions" of the format (so far)

https://en.wikipedia.org/wiki/Universally_unique_identifier#...

Re:Moving Away from UUIDs by adileo on Monday November 21, 2022 @07:13PM (#33700067)
I made a comparison list with the most known uuids out there, a couple of days ago, it was quite fun discovering all the different kinds of uid and their pros/cons.

https://adileo.github.io/awesome-identifiers/

Re:Moving Away from UUIDs by djbusby on Monday November 21, 2022 @08:49PM (#33700774)
ULID example should be in uppercase.

Love this chart tho.

Re:Moving Away from UUIDs by JimDabell on Monday November 21, 2022 @10:42PM (#33701524)
KSUIDs are fairly popular and missing from your list:

https://github.com/segmentio/ksuid

Re:Moving Away from UUIDs by 8n4vidtmkvmk on Tuesday November 22, 2022 @03:29AM (#33703408)
what's the resolution on those? 32 bits, 100 years.. that seconds right? doesn't sound excellent for time ordering. 100 years also seems a little short but at least I'll be dead
Re:Moving Away from UUIDs by sekh60 on Tuesday November 22, 2022 @06:40AM (#33704671)
Don't look at it as being your problem in 100 years, but as helping employment in 100 years and helping the economy ;)
Re:Moving Away from UUIDs by bmn__ on Wednesday November 23, 2022 @03:19AM (#33716507)
Re:Moving Away from UUIDs by ejb999 on Monday November 21, 2022 @06:27PM (#33699660)
>>Yeah I don't really get the point of this article,

To get clicks?

Re:Moving Away from UUIDs by corytheboyd on Monday November 21, 2022 @06:39PM (#33699776)
You're not wrong lol
Re:Moving Away from UUIDs by BerislavLopac on Monday November 21, 2022 @07:20PM (#33700128)
It is also highly recommended that you include a check digit into it, to minimize the chance of a collision. I've used https://arthurdejong.org/python-stdnum for that purpose.
Re:Moving Away from UUIDs by sokoloff on Monday November 21, 2022 @07:55PM (#33700421)
I don't see how a check digit minimizes the chance of collision. (Here, I'm assuming that a check digit is calculated from the other digits. What am I thinking about incorrectly?)
Re:Moving Away from UUIDs by georgemcbay on Monday November 21, 2022 @08:31PM (#33700670)
Looking at the docs for the library linked, it appears to be a Verhoeff algorithm check digit... so yeah, you're correct.

This is effectively a simplistic stand-in for a CRC type system -- useful to detect if the data has been corrupted, but not useful to avoid collisions.

Re:Moving Away from UUIDs by TedDoesntTalk on Monday November 21, 2022 @09:06PM (#33700881)
And if someone is worried about UUID collisions, they need to rethink their priorities in life.
Re:Moving Away from UUIDs by BerislavLopac on Wednesday November 23, 2022 @04:34AM (#33717022)
You are correct, this should teach me not to write comments when I'm too tired. :/

The check digit wouldn't really help with collisions, since if the strings are the same the digit will be too. They are primarily useful when we need to ensure correctness on human input.

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.

Re:Moving Away from UUIDs by _3u10 on Tuesday November 22, 2022 @04:53AM (#33703966)
Use uint128_t instead.
Re:Moving Away from UUIDs by scott_w on Tuesday November 22, 2022 @07:50AM (#33705187)
The number of comments saying "using UUIDs for secrets isn't that bad" suggests this article needs to be written...