Skip site navigation (1) Skip section navigation (2)

Re: UUID column as pimrary key?

From: Bill Moran <wmoran(at)potentialtech(dot)com>
To: Scott Ribe <scott_ribe(at)elevated-dev(dot)com>
Cc: Radosław Smogura <rsmogura(at)softperience(dot)eu>, PostgreSQL general <pgsql-general(at)postgresql(dot)org>
Subject: Re: UUID column as pimrary key?
Date: 2011-01-05 15:05:29
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-general
In response to Scott Ribe <scott_ribe(at)elevated-dev(dot)com>:

> On Jan 5, 2011, at 1:31 AM, Radosław Smogura wrote:
> > * simple to generate, and 128bit random is almost globally unique,
> Almost? Should be totally unique, as long as your random source is decent quality.

This is going off-topic, but I did some research on this because we
were considering using UUIDs for various keys ...

Fact is, UUIDs are not _guaranteed_ to be unique.  If you use the generating
system that includes a MAC address, then in theory, they are guaranteed
to be unique, but in practice, MAC addresses aren't guaranteed to be
unique either, so that's not 100% either.

Beyond that, the namespace size for a UUID is so incomprehensibly huge
that the chance of two randomly generated UUIDs having the same value
is incomprehensibly unlikely ... it is, however, not a 100% guarantee.

Anyway, in our case, we determined that the chance of UUID collision
for the dataset in question was extremely unlikely, however, the
consequences of such a collision were pretty bad.  We also determined
that we were able to control a "unit ID" for each independent system
that would generate IDs, which could (a) be part of a unique seed for
UUIDs, or (b) be a prefix to a autonumber ID that would be a lot easier
to read and work with manually.  In the end, we chose b for the human

Face it, reading, remembering, and typing UUIDs kinda sucks.

Bill Moran

In response to


pgsql-general by date

Next:From: Scott RibeDate: 2011-01-05 15:06:16
Subject: Re: UUID column as pimrary key?
Previous:From: Scott RibeDate: 2011-01-05 15:04:45
Subject: Re: UUID column as pimrary key?

Privacy Policy | About PostgreSQL
Copyright © 1996-2018 The PostgreSQL Global Development Group