'locking' the SELECTs based on indices...

Поиск
Список
Период
Сортировка
От Mario Splivalo
Тема 'locking' the SELECTs based on indices...
Дата
Msg-id 1140631350.14229.8.camel@localhost.localdomain
обсуждение исходный текст
Ответы Re: 'locking' the SELECTs based on indices...
Список 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 по дате отправления:

Предыдущее
От: Achilleus Mantzios
Дата:
Сообщение: Re: Feature, my misconception or bug??
Следующее
От: Judith
Дата:
Сообщение: Update in all tables