Re: varchar as primary key

From: Jeff Davis <pgsql(at)j-davis(dot)com>
To: Matthew Hixson <hixson(at)poindextrose(dot)org>
Cc: Postgres General <pgsql-general(at)postgresql(dot)org>
Subject: Re: varchar as primary key
Date: 2007-05-03 18:26:27
Message-ID: 1178216787.28383.281.camel@dogma.v10.wvs
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ron 2007-05-03 19:15:23 Re: Feature Request --- was: PostgreSQL Performance Tuning
Previous Message Alvaro Herrera 2007-05-03 18:25:02 Re: varchar as primary key