Re: partioning tips?

From: Josh Berkus <josh(at)agliodbs(dot)com>
To: pgsql-performance(at)postgresql(dot)org
Subject: Re: partioning tips?
Date: 2010-05-07 17:48:30
Message-ID: 4BE4526E.9050703@agliodbs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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'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

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Craig James 2010-05-07 21:11:02 Dell Perc HX00 RAID controllers: What's inside?
Previous Message Tom Lane 2010-05-07 15:35:43 Re: Planner issue on sorting joining of two tables with limit