Mario Splivalo <[EMAIL PROTECTED]> 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 ---------------------------(end of broadcast)--------------------------- TIP 9: In versions below 8.0, the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match