pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Stephan Szabo <sszabo@megazone.bigpanda.com>
To: sarlav kumar <sarlavk@yahoo.com>
Cc: pgsqlperform <pgsql-performance@postgresql.org>
Subject: Re: lock problem
Date: Sat, 4 Dec 2004 09:34:31 -0800 (PST)
Message-ID: <20041204093004.D37548@megazone.bigpanda.com> (raw)
In-Reply-To: <20041204165641.75035.qmail@web51306.mail.yahoo.com>
References: <20041204165641.75035.qmail@web51306.mail.yahoo.com>

On Sat, 4 Dec 2004, sarlav kumar wrote:

> Thanks for the information on replication tools!!
>  Now, I have a question regarding locking tables and updating tables
> that have a relationship to the locked table.
>
> I opened up two pgsql windows logged in using same userid.
> Let's say I lock a table "customerdata" on one window.
> begin;
> lock table customerdata;
>
> Then in the other window,I want to make an update to table "customer".
> begin;
> update customer set status=0 where id=111;
>
> The relation ship between the two tables is as follows
> customerdata.uid is FK on customer.id. There are no triggers that will
> try to update customerdata table when the above update statement is
> issued.
>
> My problem is the update does not continue unless the lock on
> customerdata is released. Is it because the lock statement does a lock
> on all related tables? Is it possible to lock only the particular table
> we want to lock and not the related tables?

The no action foreign key triggers grab a Row Share on the referencing
table which conflicts with the Exclusive lock that LOCK TABLE takes by
default. Depending on what you're trying to prevent, you may be able to
ask lock table for a lesser lock (see the list and descriptions here:
http://www.postgresql.org/docs/7.4/static/explicit-locking.html#LOCKING-TABLES
).



view thread (2+ messages)

Message-ID: <20041204093004.D37548@megazone.bigpanda.com>
Permalink:  ../20041204093004.D37548@megazone.bigpanda.com/
Also on:    postgresql.org/message-id/20041204093004.D37548@megazone.bigpanda.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: sszabo@megazone.bigpanda.com, sarlavk@yahoo.com
  Subject: Re: lock problem
  In-Reply-To: <20041204093004.D37548@megazone.bigpanda.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox