Re: row locking question

From: Darren Govoni <darren(at)ontrenet(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: row locking question
Date: 2008-11-18 01:26:29
Message-ID: 1226971589.27571.53.camel@nuraku
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Thank you for the suggestion.

It seems that still blocks. Here is what I'm trying to achieve.

I have 10 rows each with an id 1,2,3,4 etc.

In one thread I want to update rows with id < 4 (1-3) in my_table
inside a transaction (i.e. begin work; update where; commit work;)

In another thread I do a select * from my_table (while the first thread
is inside the transaction). I want to receive rows with id 4-10 because
rows 1-3 are currently locked and therefore not "seen".

For all I know, this isn't possible in current SQL semantics, but
would be very useful for distributed scheduling. So nodes competing to
update rows with the same query don't collide and shouldn't have to wait
on another threads updates to get some results.

I'll keep experimenting!

Darren

On Mon, 2008-11-17 at 19:37 -0500, Tom Lane wrote:
> Darren Govoni <darren(at)ontrenet(dot)com> writes:
> > For example, there is a table with many rows. Threads are doing
> > "SELECTS" to read some rows. They should be allowed to get results on
> > rows that are not currently locked by another thread's SELECT,FOR UPDATE
> > or equivalent read lock for those rows only.
>
> Make those threads use SELECT FOR SHARE.
>
> regards, tom lane
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Robert Treat 2008-11-18 02:13:55 Re: In memory Database for postgres
Previous Message Hiroshi Saito 2008-11-18 00:50:04 Re: Trying Compile libpq.dll with VC++ 9.0, but need help