From: | Mario Splivalo <mario(dot)splivalo(at)mobart(dot)hr> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | 'locking' the SELECTs based on indices... |
Date: | 2006-02-22 18:02:30 |
Message-ID: | 1140631350.14229.8.camel@localhost.localdomain |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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(dot)splivalo(at)mobart(dot)hr
"I can do it quick, I can do it cheap, I can do it well. Pick any two."
From | Date | Subject | |
---|---|---|---|
Next Message | Judith | 2006-02-22 18:08:48 | Update in all tables |
Previous Message | Judith Altamirano Figueroa | 2006-02-22 17:59:06 | Update in all tables |