Re: partioning tips? - Mailing list pgsql-performance

From Josh Berkus
Subject Re: partioning tips?
Date
Msg-id 4BE4526E.9050703@agliodbs.com
Whole thread Raw
In response to partioning tips?  (Richard Yen <dba@richyen.com>)
Responses Dell Perc HX00 RAID controllers: What's inside?
List pgsql-performance
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'mhoping to solicit some advice with respect to this.  I've looked at documentation, tried creating a prototype,
etc...lookslike 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

pgsql-performance by date:

Previous
From: Tom Lane
Date:
Subject: Re: Planner issue on sorting joining of two tables with limit
Next
From: Marcos Ortiz
Date:
Subject: Re: debugging handle exhaustion and 15 min/ 5mil row delete