Skip site navigation (1) Skip section navigation (2)

Re: Lock table, best option?

From: Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com>
To: Andre Lopes <lopes80andre(at)gmail(dot)com>
Cc: postgresql Forums <pgsql-general(at)postgresql(dot)org>
Subject: Re: Lock table, best option?
Date: 2010-04-26 07:19:02
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-general
On Sat, Apr 24, 2010 at 2:46 PM, Andre Lopes <lopes80andre(at)gmail(dot)com> wrote:
> Hi,
> I need to do a SELECT and an UPDATE, but I will have concurrent processes
> doing the same task.

If you're selecting and updating the same rows, then select ... for
update is preferred and adequate.  If you're selecting one set of rows
and updating another set / another table, then you may have to lock
the tables concerned.

> How can I prevent that the concurrent task don't have the same results in
> the SELECT? Locking a table? How can I do that?

Lock table locks a table.  But if select ... for update will work then
that is preferred.

In response to

pgsql-general by date

Next:From: Yan Cheng CHEOKDate: 2010-04-26 07:33:17
Subject: Re: Deadlock occur while creating new table to be used in partition.
Previous:From: Nikhil G. DaddikarDate: 2010-04-26 06:30:03
Subject: Postgresql on EC2/EBS in production?

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group