From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | mario(dot)splivalo(at)mobart(dot)hr |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: 'locking' the SELECTs based on indices... |
Date: | 2006-02-22 18:58:24 |
Message-ID: | 14024.1140634704@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Mario Splivalo <mario(dot)splivalo(at)mobart(dot)hr> writes:
> Now, when I do this from one connection (psql shell, for instance):
> [A]BEGIN TRANSACTION;
> [A]SELECT * FROM bla WHERE code_id = 1 FOR UPDATE;
> and then, from another psql i do:
> [B]SELECT * FROM bla WHERE code_id = 1 FOR UPDATE
> the second SELECT will wait untill I rollback or commit first
> transaction. That is cool.
> But, if I do second SELECT like this:
> [C]SELECT * FROM bla WHERE code_id = 2 FOR UPDATE
> I will get the rows.
Well, of course. Why would you want something different? Why do you
think the table's indexes should have anything to do with it?
If you want a full-table lock then some form of LOCK TABLE seems like
the proper answer. SELECT FOR UPDATE is designed to lock the specified
rows, no more.
> If I erase the index bla_idx1, then [C] select will wait, same as [B]
> select will wait.
I don't think so. If it does, it's a bug; please provide a reproducible
test case.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Scott Marlowe | 2006-02-22 19:12:10 | Re: Update in all tables |
Previous Message | Janning Vygen | 2006-02-22 18:33:36 | Re: Update in all tables |