Re: FK's to refer to rows in inheritance child

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Greg Stark <gsstark(at)mit(dot)edu>
Cc: Yeb Havinga <yebhavinga(at)gmail(dot)com>, PostgreSQL-development Hackers <pgsql-hackers(at)postgresql(dot)org>, "w(dot)p(dot)dijkstra(at)mgrid(dot)net" <w(dot)p(dot)dijkstra(at)mgrid(dot)net>
Subject: Re: FK's to refer to rows in inheritance child
Date: 2010-12-04 16:56:35
Message-ID: 24067.1291481795@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Greg Stark <gsstark(at)mit(dot)edu> writes:
> On Wed, Dec 1, 2010 at 3:05 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> Perhaps I should have said "possibly workable proposal". What you wrote
>> doesn't even begin to cover the interesting part of the problem, namely
>> how to ensure uniqueness is preserved in the face of concurrent
>> insertions.

> I think it wouldn't be very hard to implement "global indexes" which
> are just regular indexes that index records from multiple tables. The
> index tuple would have to have a relid as well as a ctid. Of course it
> would be a lot of work to touch up all the places in the source where
> indexes are assumed to reference only one table, and there may be some
> tricky parts, but the index itself wouldn't be too hard to implement.

That's been proposed before, and shot down before, though I don't recall
all the reasons offhand. One obvious problem is VACUUM, which assumes
that you can't have two processes trying to vacuum the same index
concurrently. Another is what happens when you drop one of the tables
involved in the index. Even the locking involved to make a uniqueness
check against a different table would be not-nice (locking a table after
you already have lock on its index risks deadlock against operations
going the other way).

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2010-12-04 17:08:27 Re: EXPLAIN Sort Method whitespace
Previous Message Tom Lane 2010-12-04 16:46:39 Re: Patch to add a primary key using an existing index