Re: lock table question

From: "Andy Kriger" <akriger(at)greaterthanone(dot)com>
To: "Pgsql-General" <pgsql-general(at)postgresql(dot)org>
Subject: Re: lock table question
Date: 2002-12-30 20:48:38
Message-ID: OJEFIHHAALOBKKJEOMBDGEMPCNAA.akriger@greaterthanone.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

It doesn't lock the row from being read. I want to make sure the row cannot
be read until I have done my read and updated if necessary. LOCK TABLE does
that but also prevents other rows from being read which is a bit overzealous
for my taste (the app is small so it's probably not a big deal in this case,
but I can see in future possibilities how it would be).

-----Original Message-----
From: pgsql-general-owner(at)postgresql(dot)org
[mailto:pgsql-general-owner(at)postgresql(dot)org]On Behalf Of Doug McNaught
Sent: Monday, December 30, 2002 15:18
To: Andy Kriger
Cc: Pgsql-General
Subject: Re: [GENERAL] lock table question

"Andy Kriger" <akriger(at)greaterthanone(dot)com> writes:

> I have an inventory table. I need to be able to lock a row from being
> read/written while I: check the quantity value; modify it if necessary.
From
> my experiments, it appears I can only do this with LOCK TABLE. Since this
> locks the whole table and not just the individual row, I'm guessing this
> would create quite a bottleneck if our application were larger. I'm also
> guessing that there's a better way to approach this probably common need.

Does SELECT ... FOR UPDATE not do what you want?

-Doug

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo(at)postgresql(dot)org)

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2002-12-30 21:17:08 Re: lock table question
Previous Message Medi Montaseri 2002-12-30 20:31:45 Re: pg and transactions