Re: Receiving many more rows than expected - Mailing list pgsql-general

From David G Johnston
Subject Re: Receiving many more rows than expected
Date
Msg-id 1399914636896-5803687.post@n5.nabble.com
Whole thread Raw
In response to Re: Receiving many more rows than expected  (Vincent de Phily <vincent.dephily@mobile-devices.fr>)
Responses Re: Receiving many more rows than expected  (Vincent de Phily <vincent.dephily@mobile-devices.fr>)
List pgsql-general
Did you try rewriting the query to avoid using an IN expression?

UPDATE foo SET processing = 't'
FROM (
SELECT id FROM foo WHERE processing = 'f' ORDER BY id ASC LIMIT 5000 FOR
UPDATE
) src
WHERE foo.id = src.id;

The workaround I mentioned above said that a CTE was needed but I'm thinking
that a simply FROM would be just as effective.  Otherwise:

UPDATE foo SET processing = 't'
FROM (
WITH ids_to_update AS (
SELECT id FROM foo WHERE processing = 'f' ORDER BY id ASC LIMIT 5000 FOR
UPDATE
)
SELECT id FROM ids_to_update
) src
WHERE foo.id = src.id;

David J.




--
View this message in context:
http://postgresql.1045698.n5.nabble.com/Receiving-many-more-rows-than-expected-tp5803179p5803687.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.


pgsql-general by date:

Previous
From: Vincent de Phily
Date:
Subject: Re: Receiving many more rows than expected
Next
From: Adrian Klaver
Date:
Subject: Re: Question about synchronous replication