• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Tim Cooke
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
Saloon Keepers:
  • Piet Souris
Bartenders:

Are there any issues with UUID

 
Ranch Hand
Posts: 49
1
Netbeans IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am working on an enterprise system that streams data using aws and kafka. We are using UUID for the primary key of data saved in the database and UUID for other parts of the system. Should there be any concern with collisions when using random UUID?

I ask this because one of our "architects" wants to change everything over the concern that uuid will have collisions. In my own research I have found this:

"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"

Are there any real problems with using a random UUID in java? Should my team be concern?
 
Bartender
Posts: 15743
368
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No. UUIDs are for all intents and purposes unique.

A bigger concern is that UUIDs are four times as big as an int. That may not seem like a lot, but seeing as your rows will be referenced by rows in other tables by the ID, THOSE columns will also be four times as big, etc. etc. Another issue is that UUIDs don't work well with clustered indexes.
 
John Mercier
Ranch Hand
Posts: 49
1
Netbeans IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the info. I'm not sure we even considered how the size affects things I think before we switched to uuid it was a long. The concern with uuid is actually in a different part of the system which uses a dynamodb table with documents indexed in elasticsearch. I think size should be a concern but the argument being made is to append a timestamp to the uuid which would be worse for a few reasons. I'm just trying to argue that uuid is more that sufficient for our use case and there are no gains in appending a timestamp. Thanks for the help!
 
Stephan van Hulst
Bartender
Posts: 15743
368
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think the chance of two timestamps colliding is larger than the chance of two UUIDs colliding.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic