1

Is r.uuid() guaranteed to be unique?

Return a UUID (universally unique identifier), a string that can be used as a unique ID.

How universal is r.uuid()? Is it scoped to a table/database/instance of RethinkDB? Or is it simply computing the hash of a random byte sequence (e.g. /dev/rand)? Or does it hash nano-unix time?

jpillora
  • 5,194
  • 2
  • 44
  • 56

2 Answers2

4

You can check the answers to a related question in here.

UUIDs are supposed to be uniques because of the very low probability of colisitions. Although in theory they may not be uniques as it's a random algorithm that generates the UUIDs, you will hardly generate a duplicate.

From the Wikipedia they say that for 68,719,476,736 generated UUIDs (Which it's a very huge number for a common application) you have 0.0000000000000004 for an accidental clash. It's almost impossible..

Community
  • 1
  • 1
pedromendessk
  • 3,538
  • 2
  • 24
  • 36
0

UUID means universally unique identifier. In this context the word unique should be taken to mean "practically unique" rather than "guaranteed unique". Since the identifiers have a finite size, it is possible for two differing items to share the same identifier. This is a form of hash collision.

Anyone can create a UUID and use it to identify something with reasonable confidence that the same identifier will never be unintentionally created by anyone to identify something else.

A UUID is simply a 128-bit value.

Pankaj Shinde
  • 3,361
  • 2
  • 35
  • 44
  • I'm aware of the definition, though I'm curious as to the source of the randomness for `r.uuid()` in particular. – jpillora Aug 27 '15 at 05:26
  • 1
    Then we need to explore source code in detail (https://github.com/rethinkdb/rethinkdb/blob/next/src/containers/uuid.cc) – Pankaj Shinde Aug 27 '15 at 05:28