Re: Delete all records NOT referenced by Foreign Keys - Mailing list pgsql-general

From Stephan Szabo
Subject Re: Delete all records NOT referenced by Foreign Keys
Date
Msg-id 20031214002702.X31833@megazone.bigpanda.com
Whole thread Raw
In response to Re: Delete all records NOT referenced by Foreign Keys  ("D. Dante Lorenso" <dante@lorenso.com>)
Responses Re: Delete all records NOT referenced by Foreign Keys
List pgsql-general
On Sun, 14 Dec 2003, D. Dante Lorenso wrote:

> PG already can block a delete when it knows that foreign key exists, so
> why can't I perform a query that says...
>
>     DELETE FROM tablename
>     WHERE FOREIGN_KEY_EXISTS(oid) IS FALSE;

That's fairly different from the checks that are performed for the foreign
keys which happen after the action has happened and errors to prevent the
action from being visible.  The where clause happens long before that.  If
the above has to check each referencing table for matching rows for each
row in tablename, I'd also expect it to perform poorly.

pgsql-general by date:

Previous
From: Mike Coleman
Date:
Subject: Re: make error Mac OS X (ar: illegal option -- s)
Next
From: Greg Stark
Date:
Subject: Re: Delete all records NOT referenced by Foreign Keys