X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id C01DA9DC87A for ; Wed, 22 Feb 2006 14:02:43 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 53070-05 for ; Wed, 22 Feb 2006 14:02:43 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from pjetlic.mobart.hr (pjetlic.mobart.hr [80.80.51.10]) by postgresql.org (Postfix) with ESMTP id ADEE49DC877 for ; Wed, 22 Feb 2006 14:02:41 -0400 (AST) Received: from localhost (localhost.localdomain [127.0.0.1]) by pjetlic.mobart.hr (Postfix) with ESMTP id 8FD8817A86 for ; Wed, 22 Feb 2006 19:02:39 +0100 (CET) Received: from pjetlic.mobart.hr ([127.0.0.1]) by localhost (pjetlic [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 10893-06-2 for ; Wed, 22 Feb 2006 19:02:39 +0100 (CET) Received: from [192.168.10.10] (83-131-61-42.adsl.net.t-com.hr [83.131.61.42]) (using SSLv3 with cipher RC4-MD5 (128/128 bits)) (No client certificate requested) by pjetlic.mobart.hr (Postfix) with ESMTP id 4A14017A3C for ; Wed, 22 Feb 2006 19:02:39 +0100 (CET) Subject: 'locking' the SELECTs based on indices... From: Mario Splivalo Reply-To: mario.splivalo@mobart.hr To: pgsql-sql@postgresql.org Content-Type: text/plain Organization: Mob-Art Date: Wed, 22 Feb 2006 19:02:30 +0100 Message-Id: <1140631350.14229.8.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.4.1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by OpenSource AV+AS Mail Server X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.155 required=5 tests=[AWL=0.155, UPPERCASE_25_50=0] X-Spam-Score: 0.155 X-Spam-Level: X-Archive-Number: 200602/267 X-Sequence-Number: 24277 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."