| From: | David G Johnston <david(dot)g(dot)johnston(at)gmail(dot)com> |
|---|---|
| To: | pgsql-general(at)postgresql(dot)org |
| Subject: | Re: Receiving many more rows than expected |
| Date: | 2014-05-12 17:10:36 |
| Message-ID: | 1399914636896-5803687.post@n5.nabble.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | 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.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Adrian Klaver | 2014-05-12 18:26:30 | Re: Question about synchronous replication |
| Previous Message | Vincent de Phily | 2014-05-12 16:57:58 | Re: Receiving many more rows than expected |