Re: SELECT FOR UPDATE locks whole table

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "D'Arcy J(dot)M(dot) Cain" <darcy(at)druid(dot)net>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: SELECT FOR UPDATE locks whole table
Date: 2002-12-06 23:00:24
Message-ID: 13898.1039215624@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-sql

"D'Arcy J.M. Cain" <darcy(at)druid(dot)net> writes:
> 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?

It should only lock the selected rows ... and does, in a quick test
here. Would you provide the test case that makes you think it's doing
otherwise?

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Florian Weimer 2002-12-07 00:54:44 Re: [PATCHES] Patch to make Turks happy.
Previous Message Tom Lane 2002-12-06 22:40:17 Re: GEQO Triggers Server Crash

Browse pgsql-sql by date

  From Date Subject
Next Message Josh Berkus 2002-12-06 23:25:49 Re: Rules/Trigges Trade-offs
Previous Message Joel Burton 2002-12-06 22:17:33 Re: Accent-insensitive