SELECT FOR UPDATE locks whole table

From: "D'Arcy J(dot)M(dot) Cain" <darcy(at)druid(dot)net>
To: pgsql-sql(at)PostgreSQL(dot)org
Subject: SELECT FOR UPDATE locks whole table
Date: 2002-12-06 19:03:02
Message-ID: 20021206190303.98BD31BA6@druid.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-sql

We have the following query:

SELECT certificate_id
INTO TEMP TABLE x_certs
FROM certificate
WHERE cert_status = 0 AND
certificate_id BETWEEN 1111 AND 2222 AND
client_id IN (1, 2, 3)
ORDER BY certificate_id
FOR UPDATE;

Is there any reason that this query should lock the entire certificate table?
Is there something strange because of the IN clause or because it is going
into a temporary table? This is a production server running 7.2.2 so perhaps
it is fixed in 7.3.

--
D'Arcy J.M. Cain <darcy(at){druid|vex}.net> | Democracy is three wolves
http://www.druid.net/darcy/ | and a sheep voting on
+1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner.

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2002-12-06 19:10:46 Re: SELECT FOR UPDATE locks whole table
Previous Message Tom Lane 2002-12-06 18:52:01 Re: SQL/MED spec for cross-database linkages

Browse pgsql-sql by date

  From Date Subject
Next Message Bruce Momjian 2002-12-06 19:10:46 Re: SELECT FOR UPDATE locks whole table
Previous Message Stephan Szabo 2002-12-06 18:16:17 Re: order by a "select as" determined by case statement