On Wed, Nov 16, 2016 at 02:51:35PM -0600, Jeffrey Mattox wrote:
> On Nov 16, 2016, at 8:46 AM, Richard Hipp <d...@sqlite.org> wrote:
> > 
> >> On 11/16/16, Keith Medcalf <kmedc...@dessus.com> wrote:
> >> What I do not
> >> understand is why one would use a UUID (randomly generated bunch of bytes)
> >> as a key in a database.  It is long, every use must be checked for
> >> collisions, and inherently far less efficient than the simple integer
> >> sequence it is replacing.
> > 
> > If you use good randomness to generate the UUID and if the UUID is
> > long enough, then you do not, in fact, need to check for collisions.
> > It doesn't take an excessively long UUID to make the probability of
> > collision become far less than the probability of a random cosmic ray
> > hit on your CPU causing it to give the wrong answer on a collision
> 
> I think this discussion is about apples and oranges.  UUID stands for 
> universally UNIQUE identifier, so there won't be any collisions.  It looks 
> random, but it never repeats.  Here's one: 
> "cb058c3a-ac3d-11e6-80f5-76304dec7eb7".  I use a UUID [a non-random string 
> guaranteed to be unique -- obtained via an iOS getUUID() function call] to 
> match records in two databases on different machines.  They are records for 
> individuals that occasionally have to be merged.  The UUID is acts as a 
> guaranteed unique name for each individual.

As someone mentioned in a different part of this thread, the issue is 
centralization.  If you have multiple decentralied machines generating UUIDs 
you *could* have collisions, but if you pick your UUID scheme well enough 
collisions will be extremely rare, on par with things like data loss from 
hardware failure.

Of course if you generate all your UUIDs on one machine (as you do when you 
call getUUID() on a single machine) you get guaranteed collision avoidance.

Jeremy



> 
> Jeff
> 
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to