Re: table locking

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: me(at)shanewright(dot)co(dot)uk
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: table locking
Date: 2002-02-18 15:16:15
Message-ID: 200202181516.g1IFGF517803@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Shane Wright wrote:
> Hi
>
> I'm having trouble getting my head round postgres's locking. I've read
> through all the docs but cant seem to find the right thingthat does what I
> want...
>
>
> Basically, there are a few tables in my system where a SELECT is done prior
> to an INSERT to avoid duplicating certain data and so forth.
>
> So, I want to lock the table for the transaction that does the stuff above so
> no more than one can run at a time (essentially making it SERIALIZABLE).
> But, I dont want to block other readers from SELECTing from the table at the
> same time...
>
> This is the classic multiple readers, single writer problem yes? I'm sure
> its doable, but I cant work out which locking / transaction isolation levels
> to use.

See my chapter on transactions. I think you want SERIALIZABLE
transaction mode.

http://www.postgresql.org/docs/awbook.html

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Shane Wright 2002-02-18 15:22:11 Re: table locking
Previous Message Shane Wright 2002-02-18 14:39:25 table locking