'locking' the SELECTs based on indices... - Mailing list pgsql-sql

From Mario Splivalo
Subject 'locking' the SELECTs based on indices...
Date
Msg-id 1140631350.14229.8.camel@localhost.localdomain
Whole thread Raw
Responses Re: 'locking' the SELECTs based on indices...
List pgsql-sql
I have a table, like this:

CREATE TABLE bla (id int4, code_id int4, code_value varchar, CONSTRAINT
bla_pk PRIMARY KEY (id))

And, i have index on the table:

CREATE INDEX bla_idx1 ON bla(code_id)

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.

If I erase the index bla_idx1, then [C] select will wait, same as [B]
select will wait. Is there a way to have this behaviour with the index
on column code_id?
Mario
-- 
Mario Splivalo
Mob-Art
mario.splivalo@mobart.hr

"I can do it quick, I can do it cheap, I can do it well. Pick any two."




pgsql-sql by date:

Previous
From: Achilleus Mantzios
Date:
Subject: Re: Feature, my misconception or bug??
Next
From: Judith
Date:
Subject: Update in all tables