Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 3E8A21337B53 for ; Mon, 3 Jan 2011 00:33:26 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 53546-06 for ; Mon, 3 Jan 2011 04:33:19 +0000 (UTC) X-Greylist: delayed 00:06:41.283846 by SQLgrey-1.7.6 Received: from web82104.mail.mud.yahoo.com (web82104.mail.mud.yahoo.com [209.191.84.217]) by mail.postgresql.org (Postfix) with SMTP id 9D3D31336B42 for ; Mon, 3 Jan 2011 00:33:18 -0400 (AST) Received: (qmail 52149 invoked by uid 60001); 3 Jan 2011 04:26:35 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sbcglobal.net; s=s1024; t=1294028794; bh=XYRBW93SPPyWrfpMvs5SrJahwDQMR7hpdTNWZfUXmZ4=; h=Message-ID:X-YMail-OSG:Received:X-Mailer:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=QxwKtdSS/CwVVI8n+PYc56s3QjopQwiZoG+s+Z7QOQ4cFOfZYZpopqYxOAOtVLgnA/qfbeGWvxavPVrtcGRDj2NTw6DXooReoOP5xn5p/ym2CKHjuUiCoIdnT3TKFVo+w4tRFTWADFBXK36KNvEj52GoGi5dA8TlUo7YJz48Iys= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=sbcglobal.net; h=Message-ID:X-YMail-OSG:Received:X-Mailer:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=auG5le09tXXO+OB++3eO2+s18ad3senDZjcBUIT87pfbsjeyUtGxdmkdo59ffBHxo9hJy8SjN68cXp/7QZYeLwhziY6RjjDtc6uXQ3z/TaB9mok9zm783e4hNFKh7E86F0E5GLayQDyulS56Ahv4ua/RvB3SF8WMVpQMJZG3myM=; Message-ID: <945290.45189.qm@web82104.mail.mud.yahoo.com> X-YMail-OSG: O.f.CbIVM1mIVJ9GnSJGoP7HqWj2Bzy0V09PmqJKCI_2cyl DLpJ1UeT_xLEczvV9E_Td3TppV_1BimGNAlnnC5.hvQR6.o4k1jsIhMplY4r iH7Fxy1jXF.NfINNMO9sU9eYFFQSwZYM55XwP2Q1A4LFM6LkqAJSqB6bJhdP VTTy0Wt2lDLRHXyyf9PGLzwUEF_mNlneF.4i1zUp0WUwpUTd5WzXZOKGGaWL R49BkbrZCntVazafzZVS1Z6gWUwHLMincb9JNiMN8AOYytMJKYn141mSJBPv rQ8W5dPs5uQtmXM1.9XKpM9NsJmdZFyAi.K9udwcx3hTi.J2SH0IJz_P1FyN lVx61wd2R6mH_ZXza9X5.OenLnq6NZcmUaZGLZrxW5lXbabn9sZJYDG4qpRy dcxGbllivYCH0iBSF5Q-- Received: from [75.25.120.243] by web82104.mail.mud.yahoo.com via HTTP; Sun, 02 Jan 2011 20:26:34 PST X-Mailer: YahooMailRC/553 YahooMailWebService/0.8.107.285259 Date: Sun, 2 Jan 2011 20:26:34 -0800 (PST) From: Dennis Gearon Subject: Re: uuid, COMB uuid, distributed farms To: pgsql-general@postgresql.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-5 required=5 tests=BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001 X-Spam-Level: X-Archive-Number: 201101/31 X-Sequence-Number: 171390 One of the issues with using UUIDs for primary keys, or even in a secondary= key =0Ausing a unique index,would be paging of the index because of the ra= ndomness of =0Athe values. This is what I have read, is that true for Posgr= es?=0A=0AOn the tests in this article, doing large amounts of consecutive i= nserts, =0Agenerating new UUIDs, and having the indexes getting updated cau= sed a 30 =0A(THIRTY) times increase in time to do inserts. So he came up wi= th a function =0Athat caused the lowest characters of the UUIDs to change s= lowly according to =0Atime in microseconds. This reduced the time to using = UUIDs for PKs for inserts =0Aand joins BOTH by only 10% relative to SEQUENC= ES and their integer primary keys.=0A=0AThe theory being that most of hte d= istribution in the index pages was due to the =0Alowest characters in the s= tring.=0A=0AI've made a function in PHP that makes this same 'COMB UUID' as= he coined the =0Aterm. The output of a sequence of them, as fast as my box= could make them and =0AECHO them, and put them below. When NOT echoing the= m, the lowest characters =0Achange VERY slowly. 1 MILLION of them can be ge= nerated in 3 milliseconds on my =0Ahome box, (which is not doing much else)= . to make 1 MILLION of them and store =0Athem in PHP arrays takes 3 seconds= .=0A=0AMy question, I guess repeated, is does Postgres do index distributio= n the same =0Away as the article suggests? So keeping the lower 12 characte= rs sequential and =0Aslowly changing would keep index pages in memory longe= r?=0A=0A=0A=0A=0A58cf3d06-3d94-401d-9b34-498e87a3e469=0A981a= b472-21fe-4b59-a224-498e87a3e473=0Adf2d2298-b549-4b8e-86d5-498e87a3e478=0A5= cb92685-f9d3-473a-a5e8-498e87a3e47c=0A6c4b1712-dfe8-447b-8e94-498e87a3e480= =0Ae9ab677a-812c-484e-ae71-498e87a3e484=0A2812c003-6e0b-4974-94ef-498e87a3e= 489=0A851dc2d8-9125-4410-a952-498e87a3e48d=0Aa8c695c9-6c43-4847-9bda-498e87= a3e491=0Ac2d0d9f4-37e3-417a-9611-498e87a3e495=0A3ddfd416-6568-4c2c-8ffe-498= e87a3e49a=0A471bf59a-f926-40b5-9990-498e87a3e49e=0A9d6a9876-3ba7-4133-a60f-= 498e87a3e4a2=0A01859d5f-3cde-4b83-8a1b-498e87a3e4a6=0A85321a94-5ae1-4b92-93= f2-498e87a3e4aa=0Ae74e75ae-d30f-4ba3-b8b0-498e87a3e4ae=0A62ac5bc8-1498-4d2a= -b8ef-498e87a3e4b3=0Afa597e9c-ae35-461e-b15f-498e87a3e4b7=0Af3c46abf-a6b0-4= c9c-b22d-498e87a3e4bb=0Afc868307-d1b1-4253-91d7-498e87a3e4bf=0Ab79679a9-435= 9-42a1-bf46-498e87a3e4c3=0Ad91bf8cb-e3be-4446-be73-498e87a3e4c7=0Abec9e0a1-= cd85-4f0c-b35b-498e87a3e4cc=0A0e0ea724-e145-4932-b0df-498e87a3e4d0=0A30ab3e= 05-26e3-44af-a82f-498e87a3e4d4=0A =0A=0A=0ADennis Gearon=0A= =0A=0ASignature Warning=0A----------------=0AIt is always a good idea to le= arn from your own mistakes. It is usually a better =0Aidea to learn from ot= hers=E2=80=99 mistakes, so you do not have to make them yourself. =0Afrom '= http://blogs.techrepublic.com.com/security/?p=3D4501&tag=3Dnl.e036'=0A=0A= =0AEARTH has a Right To Life,=0Aotherwise we all die.=0A