Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id B5100650218 for ; Tue, 12 Aug 2008 10:28:26 -0300 (ADT) Received: from postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 21919-03 for ; Tue, 12 Aug 2008 10:28:17 -0300 (ADT) X-Greylist: delayed 00:06:39.663965 by SQLgrey-1.7.6 Received: from smtp128.rog.mail.re2.yahoo.com (smtp128.rog.mail.re2.yahoo.com [206.190.53.33]) by postgresql.org (Postfix) with SMTP id CCE1C64FF86 for ; Tue, 12 Aug 2008 10:28:22 -0300 (ADT) Received: (qmail 88323 invoked from network); 12 Aug 2008 13:21:41 -0000 Received: from unknown (HELO ?99.245.226.206?) (markmielke@rogers.com@99.245.226.206 with plain) by smtp128.rog.mail.re2.yahoo.com with SMTP; 12 Aug 2008 13:21:41 -0000 X-YMail-OSG: L9f7oIYVM1kGDVELwDpKQXGQkBYvWFF6ppPpOtj7IdGMCpMeBZUka.qqD6maKxwDEw-- X-Yahoo-Newman-Property: ymail-3 Message-ID: <48A18E64.10707@mark.mielke.cc> Date: Tue, 12 Aug 2008 09:21:40 -0400 From: Mark Mielke User-Agent: Thunderbird 2.0.0.16 (X11/20080723) MIME-Version: 1.0 To: Bill Moran CC: Gregory Stark , Mario Weilguni , valiouk@yahoo.co.uk, Jay , pgsql-performance@postgresql.org Subject: Re: Using PK value as a String References: <18986.60888.qm@web25807.mail.ukl.yahoo.com> <48A15ECF.5030203@sime.com> <87od3ywg4n.fsf@oxford.xeocode.com> <20080812090621.1cafbbab.wmoran@collaborativefusion.com> In-Reply-To: <20080812090621.1cafbbab.wmoran@collaborativefusion.com> Content-Type: multipart/alternative; boundary="------------040500010500070702070402" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.001 tagged_above=0 required=5 tests=HTML_MESSAGE=0.001 X-Spam-Level: X-Archive-Number: 200808/119 X-Sequence-Number: 31000 This is a multi-part message in MIME format. --------------040500010500070702070402 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Bill Moran wrote: >> 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. > Other benefits include: - Reduced management cost. As described above, one would have to allocate keyspace in each system. By using a UUID, one can skip this step. - Increased keyspace. Even if keyspace allocation is performed, an int4 only has 32-bit of keyspace to allocate. The IPv4 address space is already over 85% allocated as an example of how this can happen. 128-bits has a LOT more keyspace than 32-bits or 64-bits. - Reduced sequence predictability. Certain forms of exploits when the surrogate key is exposed to the public, are rendered ineffective as guessing the "next" or "previous" generated key is far more difficult. - Used as the key into a cache or other lookup table. Multiple types of records can be cached to the same storage as the sequence is intended to be universally unique. - Flexibility to merge systems later, even if unplanned. For example, System A and System B are run independently for some time. Then, it is determined that they should be merged. If unique keys are specific to the system, this becomes far more difficult to implement than if the unique keys are universal. That said, most uses of UUID do not require any of the above. It's a "just in case" measure, that suffers the performance cost, "just in case." Cheers, mark -- Mark Mielke --------------040500010500070702070402 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Bill Moran wrote:
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.
  

Other benefits include:
    - Reduced management cost. As described above, one would have to allocate keyspace in each system. By using a UUID, one can skip this step.
    - Increased keyspace. Even if keyspace allocation is performed, an int4 only has 32-bit of keyspace to allocate. The IPv4 address space is already over 85% allocated as an example of how this can happen. 128-bits has a LOT more keyspace than 32-bits or 64-bits.
    - Reduced sequence predictability. Certain forms of exploits when the surrogate key is exposed to the public, are rendered ineffective as guessing the "next" or "previous" generated key is far more difficult.
    - Used as the key into a cache or other lookup table. Multiple types of records can be cached to the same storage as the sequence is intended to be universally unique.
    - Flexibility to merge systems later, even if unplanned. For example, System A and System B are run independently for some time. Then, it is determined that they should be merged. If unique keys are specific to the system, this becomes far more difficult to implement than if the unique keys are universal.

That said, most uses of UUID do not require any of the above. It's a "just in case" measure, that suffers the performance cost, "just in case."

Cheers,
mark

-- 
Mark Mielke <mark@mielke.cc>
--------------040500010500070702070402--