Is it safe to pre-generate a Guid and insert it into a table as the primary key?
Some info: the number of values that 16 bytes can store is 2 ^ 128.
Total = number of common values that can be represented
Actual = number of values that have already been used
The probability of inserting an identifier into an already existing table can be formulated as follows:
1 - (Total - Actual) / Total
I did some preliminary calculations and I came up with the following:
Let's say you had a table with 10 million records in the table, then the probability would be
1 - (2 ^ 128 - 10,000,000) / 2 ^ 128
which appromixately
0.00000000000000000000000000000003
I think now I know why he said that:
"While each generated GUID is not guaranteed to be unique, the total number of unique keys is so great that the likelihood that the same number is generated twice is infinitesimal."
a source to share