Categories
Technology

Are GUIDs actually unique?

No.

This could potentially be the shortest blog post ever written, and the short mathematically accurate answer is “no”. A GUID (globally unique identifier) is a 32 character sequence of  alphanumeric (letters or numbers). They are useful to developers because, in theory when generated, no GUID like this has been generated before, nor will another be generated again.

However, for anyone who understands what “always forever” means in math, this should immediately ring false. There is a limit to the number of GUIDs that can be generated. However, that limit has a very high ceiling, and that’s what is so fascinating about them.

Bear with me through a little math for a moment. GUIDs are generated using 6 fixed bits and 122 random bits1. The fixed bits contain the version of the GUID generation algorithm being used, and previously contained the machines MAC address (though this was changed as it exposed a privacy hole where one could locate the machine a GUID was generated at). This means there are 2^122, or 5.2 x 10^361, or about 5 trillion trillion trillion unique GUIDs.

Statistically, it’s a very safe assumption to expect that a generated GUID is totally unique across all systems for all time, which blows my mind. You are being provided something seemingly mathematically impossible. Something (almost) unique, but something that we can tangibly touch and view, within the confines of just 32 alphanumeric characters.

I like to think that every time I programmatically generate a GUID that I’m going to some giant reservoir at the center of the Universe that contains all GUIDs and stealing one. However, emptying this reservoir would actually be more feeble than going to the ocean2 and trying to empty it by taking out one droplet water at a time (mathematically actually, about 200 trillion times as feeble, since by size comparison every drop of water in the ocean would represent 200 trillion GUIDs).

Every once in awhile I stare at a list of generated test data containing GUIDs in a bit of awe. I feel a slight sense of loss when deleting that test data knowing the likelihood of any one of those exact GUIDs being generated is less likely than winning the lotto 6/49 jackpot 5 times in a row3. So I commend you to all, developer or not, to respect the GUID. It is a way of glimpsing at a tiny corner of infinity, which even in this reduced format is quite a phenomenon to ponder.

Want to take one away from the universe?
You already have (refresh the page to take more):

%CODE1%

References:

Stack overflow for some initial inspiration, here

1 ^ http://en.wikipedia.org/wiki/Globally_unique_identifier
2 ^ Calculated using the oceans volume from http://oceanservice.noaa.gov/facts/oceanwater.html
3 ^ Calculated using the probability referenced at http://www.moneysense.ca/spend/how-to-win-the-lottery-2

71 replies on “Are GUIDs actually unique?”

It’s appropriate time to make some plans for the future and it’s time to be happy. I have read this post and if I could I wish to suggest you some interesting things or tips. Perhaps you can write next articles referring to this article. I wish to read more things about it!

Have you ever considered writing an ebook or guest authoring on other websites? I have a blog centered on the same subjects you discuss and would love to have you share some stories/information. I know my viewers would enjoy your work. If you are even remotely interested, feel free to shoot me an e mail.

When I originally commented I clicked the -Notify me when new comments are added- checkbox and now each time a comment is added I get four emails with the same comment. Is there any way you can remove me from that service? Thanks!

Very nice post. I just stumbled upon your blog and wanted to say that I’ve really enjoyed browsing your blog posts. In any case I’ll be subscribing to your rss feed and I hope you write again soon!

Leave a Reply

Your email address will not be published. Required fields are marked *