Received: from maia.hub.org (maia-4.hub.org [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 1BE75632436 for ; Fri, 7 May 2010 14:48:43 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 55214-06 for ; Fri, 7 May 2010 17:48:35 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from glacier.frostconsultingllc.com (glacier.frostconsultingllc.com [69.36.227.170]) by mail.postgresql.org (Postfix) with ESMTP id 9D8ED632337 for ; Fri, 7 May 2010 14:48:35 -0300 (ADT) Received: from dsl081-245-111.sfo1.dsl.speakeasy.net ([64.81.245.111] helo=[192.168.1.118]) by glacier.frostconsultingllc.com with esmtpsa (TLSv1:CAMELLIA256-SHA:256) (Exim 4.69) (envelope-from ) id 1OARf5-0007b7-I8 for pgsql-performance@postgresql.org; Fri, 07 May 2010 10:48:34 -0700 Message-ID: <4BE4526E.9050703@agliodbs.com> Date: Fri, 07 May 2010 10:48:30 -0700 From: Josh Berkus User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.9pre) Gecko/20100217 Shredder/3.0.3pre MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Re: partioning tips? References: <0E1248CD-551D-4F40-95AD-17336996ADAF@richyen.com> In-Reply-To: <0E1248CD-551D-4F40-95AD-17336996ADAF@richyen.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-10 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201005/27 X-Sequence-Number: 38611 On 05/05/2010 01:25 PM, Richard Yen wrote: > Problem is, I have foreign keys that link almost all of our tables together (as a business requirement/IT policy). However, I know (er, I have a gut feeling) that many people out there have successfully deployed table partitioning, so I'm hoping to solicit some advice with respect to this. I've looked at documentation, tried creating a prototype, etc...looks like foreign keys have to go. But do they? What have other people out there done to get their tables partitioned? Well, it's possible to work around the limitation on FKs, but probably not worth it. In general, the reasons you want to partition (being able to cheaply drop segments, no scans against the whole table, ever) are reasons why you wouldn't want an FK to a partition table in any case. The specific cases where it works to have FKs anyway are: 1) if you're making FKs between two partitioned tables whose partition ranges match exactly. In this case, you can just FK the individual partitions (there is a TODO, and some draft code from Aster, to make this happen automatically). 2) If the partitioned table has very wide rows, and it's large for that reason rather than because of having many rows. In this case, you can create an FK join table containing only the SKs for creating FKs to, just like a many-to-many join table. -- -- Josh Berkus PostgreSQL Experts Inc. http://www.pgexperts.com