Re: SELECT FOR UPDATE locks whole table - Mailing list pgsql-sql

From Tom Lane
Subject Re: SELECT FOR UPDATE locks whole table
Date
Msg-id 13898.1039215624@sss.pgh.pa.us
Whole thread Raw
In response to SELECT FOR UPDATE locks whole table  ("D'Arcy J.M. Cain" <darcy@druid.net>)
List pgsql-sql
"D'Arcy J.M. Cain" <darcy@druid.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


pgsql-sql by date:

Previous
From: Joel Burton
Date:
Subject: Re: Accent-insensitive
Next
From: Josh Berkus
Date:
Subject: Re: Rules/Trigges Trade-offs