I use Visual Studio GUID tool to generate two GUID. Well, they are suppose to be unique. However, when I run my SQL project build. an error message pop out, and it says The GUID {eeb5e80a-8162-40d6-8c3a-f2408152e325} has hash collision with /*place holder for another GUID */

They are definately are different GUID value, but why I receive this error? So I quickly generate another GUID from VS tool, and it pass the build.

Okay here is the question. Is the hash of a GUID unique?

For GUID

GUIDs are usually stored as 128-bit values, and are commonly displayed as 32 hexadecimal digits with groups separated by hyphens, such as:

21EC2020-3AEA-4069-A2DD-08002B30309DThey may or may not be generated from random (or pseudo-random) numbers. GUIDs generated from random numbers normally contain 6 fixed bits (these indicate that the GUID is random) and 122 random bits; the total number of unique such GUIDs is 2^122^ (approximately 5.3×10^36^).

Apparently GUID is unlikely duplicate, but what about the hash collision about GUID. aha, it is a little bit tricky after think about twice this question. It depends on how do you hash it, isn’t it?

The point of hashing is you can use hash function to make a quickly search, but remember hash key is always more than the bucket. According to the quote above, we know that There is 2^122^ unique GUID. If the return hash code for the GUID is, let’s say integer, 64 bits. There are 2^64^ hash Code, then pigeonhole principle tells us it is not unique. It will have GUIDs got hash collision. It really depends on the implementation of the hash function.

Okay, so I am just unlucky to face this problem.