Partitioned Tables Foreign Key Constraints Problem

From: "Gauri Kanekar" <meetgaurikanekar(at)gmail(dot)com>
To: pgsql-performance(at)postgresql(dot)org
Subject: Partitioned Tables Foreign Key Constraints Problem
Date: 2008-07-24 10:15:41
Message-ID: 7e4ba9550807240315q22c955a7t4c3895b94aa2138d@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Hi all,

Have a problem related to partition tables.

We have the following schema's :

master -
id integer (PRIMARY KEY)
cid integer

child1, child2 are the child tables of master table. Here "cid" is the field
used for partitioning.

We have another table called
other_tbl -
id integer (PRIMARY KEY)
m_id integer (FOREIGN KEY FROM master(id))

Now the problem is, since other_tbl->m_id referenced from master->id, if we
try to insert any vales in "other_tbl" for m_id its checks it presence in
only master table and not in its child table. As the master table is always
empty in partitions tables a foreign key violation ERROR is being given.

How can we define the Foreign_key constraint on "other_tbl" based upon any
partitioned table field.

--
Regards
Gauri

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Josh Berkus 2008-07-25 22:31:55 Re: Partitioned Tables Foreign Key Constraints Problem
Previous Message Richard Huxton 2008-07-24 08:44:03 Re: how to fix problem then when two queries run at the same time, it takes longer to complete then if run in sequence