Re: WIP: Deferrable unique constraints

From: Greg Stark <gsstark(at)mit(dot)edu>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Dean Rasheed <dean(dot)a(dot)rasheed(at)googlemail(dot)com>, Jeff Davis <pgsql(at)j-davis(dot)com>, David Fetter <david(at)fetter(dot)org>, Alvaro Herrera <alvherre(at)commandprompt(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: WIP: Deferrable unique constraints
Date: 2009-07-27 22:43:04
Message-ID: 407d949e0907271543k72a22e43n81df593c4f74c6b7@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Jul 27, 2009 at 7:51 PM, Tom Lane<tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> (In fact, in a real sense these ARE join problems ... maybe we should
> stop thinking of them as fire-a-bunch-of-triggers and instead think of
> executing a single check query with appropriate WHERE clause ...)

A while back I suggested keeping the deferred trigger list in
tuplestore format and executing the trigger check as a query between
the materialized tuplestore of and the tuples on disk.

I love the idea of doing a full SQL query but the problem is that
there's no particular reason to assume that a deferred trigger list
large enough to warrant a wholesale check is actually a significant
percentage of the table. It might only take a few hundred or few
thousand checks to warrant a bitmap index scan instead of repeated
index probes but a plain SQL query with no reference back to the
deferred list would have to check all the millions of rows in the
table for no purpose.

For foreign keys I was picturing some way to issue an SQL statement
like "SELECT from tabletocheck where ctid in (<magic parameter>) and
not exists (select 1 from referenced_table where pk =
tabletocheck.fk)" and then somehow pass the list of ctids from the
deferred list.

--
greg
http://mit.edu/~gsstark/resume.pdf

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2009-07-27 23:04:38 Re: WIP: Deferrable unique constraints
Previous Message Andrew Dunstan 2009-07-27 20:55:49 Re: SRPMs?