Re: UUID column as pimrary key?

From: Michael Satterwhite <michael(at)weblore(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: UUID column as pimrary key?
Date: 2011-01-05 23:11:35
Message-ID: 201101051711.35715.michael@weblore.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I've been enjoying this discussion, but it seems to me there are two
possibilities that guarantee unique results, use less storage, and neither
would use a UUID for the primary key.

The first would assume that only one machine is doing the work on the database.
As has been pointed out earlier, in this case the simplest solution would be
to simply use a series. As that is guaranteed unique on a single machine and
is incredibly simple to implement.

Once multiple machines are linked to maintain the database, this has a flaw in
it as a series is not guaranteed to be unique between machines (actually I
think they're pretty well guaranteed *NOT* to be, but that's another issue. In
that case, another field is needed as follows:

Create table test
( id serial,
machine_id integer,
.....
primary_key(machine_id, id);
)

Each machine would have a unique machine_id. This would guarantee uniqueness
and be very easy to maintain. In addition - *IF* it were ever necessary - it
would be easy to determine which machine generated records.

OK, I'm probably going to regret jumping in here, but I couldn't resist.

Sorry

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Chris Browne 2011-01-05 23:22:08 Re: UUID column as pimrary key?
Previous Message Rob Sargent 2011-01-05 22:49:01 Re: UUID column as pimrary key?