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 23:07:18
Message-ID: OJEFIHHAALOBKKJEOMBDCENECNAA.akriger@greaterthanone.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I agree which is why I'm asking the question. In this case, I'm trying to
ensure that my inventory quantity is not changed by some other request as
the first one does a test of availability and then decrements that
availability.

After various responses, it looks like SELECT...FOR UPDATE does fit the bill
if I use it consistently for querying the records I'm interested in.

I'm no psql expert, so every day it's something new to add to my toolkit.
-a

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

"Andy Kriger" <akriger(at)greaterthanone(dot)com> writes:
> 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.

Why?

You're really swimming upstream against the notion of MVCC if you want
to prevent pure readers from proceeding while your update transaction
runs. Since you claim to be concerned about bottlenecks, I do not see
why you shouldn't embrace the MVCC worldview, rather than fighting it
tooth and nail.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
message can get through to the mailing list cleanly

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2002-12-30 23:13:08 Re: lock table question
Previous Message Manfred Koizar 2002-12-30 21:30:05 Re: lock table question