Re: UUID performance as primary key

From: Craig James <craig_james(at)emolecules(dot)com>
To: Navkirat Singh <navkirats(at)gmail(dot)com>, pgsql-performance(at)postgresql(dot)org
Subject: Re: UUID performance as primary key
Date: 2010-10-16 17:28:41
Message-ID: 4CB9E0C9.4090702@emolecules.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On 10/15/10 6:58 PM, Navkirat Singh wrote:
> I am interested in finding out the pros/cons of using UUID as a
> primary key field. My requirement states that UUID would be perfect
> in my case as I will be having many small databases which will link
> up to a global database using the UUID. Hence, the need for a unique
> key across all databases.

You left out one piece of information: How many keys per second do you need?

We put a sequence in the global database that all secondary databases use to get their IDs. It means an extra connect/disconnect (a pooler can minimize this), so if you're issuing thousands of IDs per second, this isn't a good idea. But for a small-ish number of IDs per second, it gets you the benefit of a universal ID without the size of the UUID field.

Craig (the other one)

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Kenneth Marshall 2010-10-16 18:44:43 Re: Select count(*), the sequel
Previous Message Mladen Gogala 2010-10-16 16:53:50 Select count(*), the sequel