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.