> On Nov 16, 2016, at 5:59 AM, 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.
Distributed databases such as CouchDB and Couchbase do this. (I work on Couchbase Mobile.) When a database record is to be replicated between any number of peer databases, it obviously becomes infeasible to assign it a simple auto-incremented integer. (You’d have to assign a central ‘count server’ to hand out consecutive numbers, and then your system becomes bottlenecked on that server; it limits the rate at which the entire system can create records, and becomes a single point of failure.) You can assign ‘peer IDs’, but then you need a sure-fire-unique way to assign them (using the MAC address is not sure-fire-unique) and the system has to keep a persistent counter that can’t ever be rolled back, even in the case of something like restoring an OS backup. You can use a timestamp to try to avoid rollback problems, but now you’ve added the well-known problems of using clocks in a distributed system. Worse, you’ve started leaking a significant amount of interesting information about your computer, which in some cases can be a privacy problem. In the face of all that, simply generating a sufficiently long cryptographically-random number is very attractive. > THe problem is an inability to properly determine and assess risk. When > using a sequence the probability of a collision is 0. When using a random > generated number (passing a bunch of random data through a digest function) > has a probability of collision of 100%. Um. Either you’re trolling me, or you don’t have a good understanding of probability. In any case, this thread is pretty far off-topic and we should stop arguing this. I will not respond to any further posts. —Jens _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users