Re: UUID column as pimrary key? - Mailing list pgsql-general

From Michael Satterwhite
Subject Re: UUID column as pimrary key?
Date
Msg-id 201101051711.35715.michael@weblore.com
Whole thread Raw
In response to Re: UUID column as pimrary key?  (Andrew Sullivan <ajs@crankycanuck.ca>)
Responses Re: UUID column as pimrary key?  (Radosław Smogura <rsmogura@softperience.eu>)
Re: *****SPAM***** Re: UUID column as pimrary key?  (Scott Ribe <scott_ribe@elevated-dev.com>)
List 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

pgsql-general by date:

Previous
From: Rob Sargent
Date:
Subject: Re: UUID column as pimrary key?
Next
From: dennis jenkins
Date:
Subject: Re: UUID column as pimrary key?