0

Is UUID really unique? I think that it can be not unique. A UUID is composed of 128 bits, so there are no more than 2^128 different UUIDs. So, if a computer generates (2^128+1) UUIDs, then there must be two UUIDs that are the same.

zhoudu
  • 623
  • 8
  • 19
  • 2
    Possible duplicate of [Is a GUID unique 100% of the time?](http://stackoverflow.com/questions/39771/is-a-guid-unique-100-of-the-time) – James Thorpe Jan 10 '17 at 10:51
  • Its a big number - the probability of collisions is very low. – Jay Jan 10 '17 at 10:52
  • `there are no more than 2^128 different UUIDs` ... This is a huge number. – Tim Biegeleisen Jan 10 '17 at 10:52
  • 1
    Note that duplicates are only an issue if they're used for the same thing. I could generate the same GUID for use in my application as you in yours, but they'll never clash since they're in totally different spaces, further reducing the chance that a duplicate actually causes a problem. – James Thorpe Jan 10 '17 at 10:53
  • Are UUID and GUID the same thing? – zhoudu Jan 10 '17 at 11:29
  • [Yes](http://stackoverflow.com/questions/246930/is-there-any-difference-between-a-guid-and-a-uuid) - I'm an MS-based guy, so GUID comes more naturally to me :) – James Thorpe Jan 10 '17 at 11:33
  • Thank you. But, it seems that UUID only guarantees that the probability of generating two same UUIDs is very small. What do many softwares do? Do they just presume that UUIDs are always unique? Do they do any uniqueness check of UUIDs? – zhoudu Jan 11 '17 at 08:36

1 Answers1

0

Your assumption is correct.

Due to the pigeonhole principle, it is mandatory that (2^128) + 1 UUIDs will have at least one duplicate since there are only (2^128) possibilities.

Victor Maricato
  • 672
  • 8
  • 25