From: Josh Berkus <josh@agliodbs.com>
To: pgsql-performance@postgresql.org
Subject: Re: partioning tips?
Date: Fri, 07 May 2010 10:48:30 -0700
Message-ID: <4BE4526E.9050703@agliodbs.com> (raw)
In-Reply-To: <0E1248CD-551D-4F40-95AD-17336996ADAF@richyen.com>
References: <0E1248CD-551D-4F40-95AD-17336996ADAF@richyen.com>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: josh@agliodbs.com
Subject: Re: partioning tips?
In-Reply-To: <4BE4526E.9050703@agliodbs.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox