Re: foreign key causing unwanted record lock

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: "Donahue, Pat" <Pat(dot)Donahue(at)MSFC(dot)NASA(dot)GOV>
Cc: "'pgsql-general(at)postgresql(dot)org'" <pgsql-general(at)postgresql(dot)org>
Subject: Re: foreign key causing unwanted record lock
Date: 2002-04-05 21:35:43
Message-ID: 20020405133020.P32926-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, 5 Apr 2002, Donahue, Pat wrote:

> > Table A Field 1 has a foreign key relationship with Table B Field 2. When
> > I do an Insert into Table A, Postgres seems to be taking an exclusive lock
> > on the record in Table B where Field 2 matches Field 1 in Table A (until
> > the Insert is committed). This doesn't make sense to me. Can someone
> > help me understand this? This lock is causing major throughput problems.

The lock is overly strong for what it needs to do, but it was the
available row lock. We need to make sure that the rows don't fall out from
underneath us (for example, if TableB's row was waiting deletion when
Table A goes to insert a row - that's not an error by our reading if the
other transaction aborts, but we don't know that yet).
Hopefully for 7.3 (with Alex Hayward's suggestions on hackers) we'll
no longer have concurrent inserts on TableA blocking each other.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Andreas Scherbaum 2002-04-05 21:48:30 setuid functions
Previous Message Josh Burdick 2002-04-05 21:32:04 why "Seq Scan" instead of "Index Scan" ?