Re: INSERT/SELECT and excessive foreign key checks

From: Gregory Stark <stark(at)enterprisedb(dot)com>
To: "Lodewijk Voege" <lvoege(at)gmail(dot)com>
Cc: <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: INSERT/SELECT and excessive foreign key checks
Date: 2007-08-19 10:17:04
Message-ID: 87ejhzsuan.fsf@oxford.xeocode.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

"Lodewijk Voege" <lvoege(at)gmail(dot)com> writes:

> I hacked up a patch that handles these two cases:
> - for such an INSERT/SELECT, check constant FKs only once.

This sounds like a clever idea. It seems the abstraction violation is worth it
to me.

> - for an INSERT/SELECT from/to the same table, don't check FKs that are
> carried over as is at all. (it'd be nice to extend this to fields that
> have the same FK constraint, rather than the current patch' strict
> same-table, same-field condition)

I'm not sure this is safe. It means you're not locking the target row. If
someone else comes along and deletes both the original source record and the
target record before you've gotten around to inserting the new record...

--
Gregory Stark
EnterpriseDB http://www.enterprisedb.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2007-08-19 11:44:45 Re: INSERT/SELECT and excessive foreign key checks
Previous Message Andrew Dunstan 2007-08-19 03:23:38 Re: change name of redirect_stderr?