3 ms·
> combining time + random number You can't guarantee that this will be globally unique.
by stronglikedan 3y ago
> combining time + random number
You can't guarantee that this will be globally unique.
- ceejayoz 3y agoNo identifier can guarantee that. We just get close enough to be acceptable. Per Wikipedia, the probability to find a duplicate within 103 trillion version-4 UUIDs is one in a billion. so-youre-saying-theres-a-chance.gif
- duped 3y agoA billion is not that big of a number for UUIDs
- ceejayoz 3y agoRe-read. You'd have to generate 103 trillion to have a one billionth chance of a collision. A billion isn't that big a number, but 103 trillion is.
- jandrewrogers 3y agoI think you made a mistake in your math. The Birthday Collision probability of just a trillion random UUID is much higher than that.
- ceejayoz 3y agoFeel free to update https://en.wikipedia.org/wiki/Universally_unique_identifier#Collisions https://en.wikipedia.org/wiki/Universally_unique_identifier#..., but it does note "This probability can be computed precisely based on analysis of the birthday problem". It does show the formula used.
- deathanatos 3y agoWikipedia is correct, AFAICT. The probability of 1 trillion UUIDs having a collision is, def birthday_collision(n, m): return 1 - math.e ** (-((n -1) * n) / (2 * m)) In : birthday_collision(1_000_000_000_000, 2 ** 122) Out: 9.403589018575076e-14 That number is roughly the approximation given in Wikipedia. I.e., at 1T UUIDs, it hasn't happened. For comparison, the odds of being struck by lighting (over a lifetime) is many orders of magnitude greater: 6.535947712418301e-05
- jandrewrogers 3y agoI have single datasets with trillions of UUID. Collision probability becomes a thing. That aside, UUIDv4 is banned in many orgs because there have been several instances in the wild where the “random” number wasn’t nearly as random as advertised from some sources for a variety of reasons, leading to collisions. It is relatively easy to screw this up so many orgs don’t risk it.
- vore 3y agoA 1 in a billion collision probability?
- deleted 3y ago[deleted]