Re: Using PK value as a String - Mailing list pgsql-performance

From Bill Moran
Subject Re: Using PK value as a String
Date
Msg-id 20080812090621.1cafbbab.wmoran@collaborativefusion.com
Whole thread Raw
In response to Re: Using PK value as a String  (Gregory Stark <stark@enterprisedb.com>)
Responses Re: Using PK value as a String  (Mark Mielke <mark@mark.mielke.cc>)
List pgsql-performance
In response to Gregory Stark <stark@enterprisedb.com>:

> "Mario Weilguni" <mweilguni@sime.com> writes:
>
> > UUID is already a surrogate key not a natural key, in no aspect better than a
> > numeric key, just taking a lot more space.
> >
> > So why not use int4/int8?
>
> The main reason to use UUID instead of sequences is if you want to be able to
> generate unique values across multiple systems. So, for example, if you want
> to be able to send these userids to another system which is taking
> registrations from lots of places. Of course that only works if that other
> system is already using UUIDs and you're all using good generators.

Note that in many circumstances, there are other options than UUIDs.  If
you have control over all the systems generating values, you can prefix
each generated value with a system ID (i.e. make the high 8 bits the
system ID and the remaining bits come from a sequence)  This allows
you to still use int4 or int8.

UUID is designed to be a universal solution.  But universal solutions
are frequently less efficient than custom-tailored solutions.

--
Bill Moran
Collaborative Fusion Inc.
http://people.collaborativefusion.com/~wmoran/

wmoran@collaborativefusion.com
Phone: 412-422-3463x4023

pgsql-performance by date:

Previous
From: Gregory Stark
Date:
Subject: Re: Using PK value as a String
Next
From: Mark Mielke
Date:
Subject: Re: Using PK value as a String