Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
just add a primary key on the uuid field and you will get an exception, if two uuid are the same.
Edit: And you get a faster search. What DBMS do you use? -
Root825995y@magicMirror "low chance" means "still a chance."
Admittedly small, but the debugging to find the issue in a year or so would not be. -
https://wikiwand.com/en/...
"
For example, the number of random version-4 UUIDs which need to be generated in order to have a 50% probability of at least one collision is 2.71 quintillion, computed as follows:[14]
<skipped>
This number is equivalent to generating 1 billion UUIDs per second for about 85 years, and a file containing this many UUIDs, at 16 bytes per UUID, would be about 45 exabytes, many times larger than the largest databases currently in existence, which are on the order of hundreds of petabytes
"
I think your website is gonna be fine..
@Root FYI -
Root825995y@netikras Most of what makes a UUID unique is an encoded timestamp. If you generate multiple UUIDs simultaneously, the timestamp portion would (obv) be identical, significantly increasing the collision chance.
Still a low chance, but worth considering depending on scale/throughput. -
@Root sure, because 2bln IDs per second is something likely to happen and needs to be taken into account :) FK (unique) constraints won't protect us here..
-
If it should be unique...
Use as PK or add an unique index to it.
Mostly for the optimizer, but to make and leave an clear intent of what the column does. -
@Root as I said: low chance. I will take that risk. Others don't belive in hash functions. 🤷♂️
Related Rants
Storing unique v4 uuids in db, collision detect or not?
question
slacking
uuids