Re: varchar as primary key - Mailing list pgsql-general

From Jeff Davis
Subject Re: varchar as primary key
Date
Msg-id 1178216787.28383.281.camel@dogma.v10.wvs
Whole thread Raw
In response to varchar as primary key  (Matthew Hixson <hixson@poindextrose.org>)
Responses Re: varchar as primary key
List pgsql-general
On Thu, 2007-05-03 at 08:58 -0700, Matthew Hixson wrote:
> I'm investigating the usage of a UUID primary key generator using
> Hibernate and Postgres.  The reason for using a UUID is that we will
> have an application hosted at different sites in different
> databases.  We will need to aggregate the data back into a single
> database from time to time and we want to avoid PK collisions.
>    Is there a significant performance difference between using int
> primary keys and string primary keys in Postgres?

If the only thing you need to do is avoid primary key collisions, why
not just store an extra int that represents the "site ID" and have a
primary key on (the_key, site_id)?

That way you're *sure* no collisions happen. A UUID has a lot of bits,
but if the random generator is flawed a collision can still happen.

Regards,
    Jeff Davis


pgsql-general by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: varchar as primary key
Next
From: "Alexander Staubo"
Date:
Subject: Re: varchar as primary key