Re: deferred foreign keys

From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
To: Rod Taylor <pg(at)rbt(dot)ca>
Cc: Vivek Khera <khera(at)kcilink(dot)com>, Postgresql Performance <pgsql-performance(at)postgresql(dot)org>
Subject: Re: deferred foreign keys
Date: 2004-01-05 22:33:17
Message-ID: 20040105143127.I76870@megazone.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Mon, 5 Jan 2004, Rod Taylor wrote:

> On Mon, 2004-01-05 at 14:48, Stephan Szabo wrote:
> > On Mon, 5 Jan 2004, Vivek Khera wrote:
> >
> > >
> > > On Jan 5, 2004, at 1:57 PM, Stephan Szabo wrote:
> > >
> > > > But, if he's updating the fk table but not the keyed column, it should
> > > > no
> > > > longer be doing the check and grabbing the locks. If he's seeing it
> > > > grab
> > > > the row locks still a full test case would be handy because it'd
> > > > probably
> > > > mean we missed something.
> > > >
> > >
> > > I'm not *sure* it is taking any locks. The transactions appear to be
> > > running lock step (operating on different parts of the same pair of
> > > tables) and I was going to see if deferring the locks made the
> > > difference. It is my feeling now that it will not. However, if there
> > > is a way to detect if locks are being taken, I'll do that. I'd like to
> > > avoid dropping and recreating the foreign keys if I can since it takes
> > > up some bit of time on the table with 20+ million rows.
> >
> > The only way I can think of to see the locks is to do just one of the
> > operations and then manually attempting to select for update the
> > associated pk row.
>
> When a locker runs into a row lock held by another transaction, the
> locker will show a pending lock on the transaction id in pg_locks.

Yeah, but AFAIR that won't let you know if it's blocking on the particular
row lock you're expecting.

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Paul Tuckfield 2004-01-06 00:24:26 Re: Select max(foo) and select count(*) optimization
Previous Message Christopher Browne 2004-01-05 20:27:43 Re: Use my (date) index, darn it!