Re: partioning tips?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

--
Sent via pgsql-performance mailing list (pgsql-performance@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance

[Postgresql General]     [Postgresql PHP]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Yosemite]

  Powered by Linux