| From: | Shaun Thomas <sthomas(at)optionshouse(dot)com> |
|---|---|
| To: | Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Dave Johansen <davejohansen(at)gmail(dot)com> |
| Cc: | Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com>, Jeff Janes <jeff(dot)janes(at)gmail(dot)com>, pgsql-performance <pgsql-performance(at)postgresql(dot)org> |
| Subject: | Re: Recommendations for partitioning? |
| Date: | 2013-12-20 16:18:21 |
| Message-ID: | 52B46DCD.2070107@optionshouse.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-performance |
On 12/20/2013 09:59 AM, Alvaro Herrera wrote:
> WITH moved AS (
> DELETE FROM src WHERE ..
> RETURNING *
> ) INSERT INTO dst SELECT * FROM moved;
I know that's effectively an atomic action, but I'd feel a lot more
comfortable reversing that logic so the delete is based on the results
of the insert.
WITH saved AS (
INSERT INTO dst
SELECT * FROM src WHERE ...
RETURNING *
)
DELETE FROM src
WHERE ...;
I'll admit yours is cleaner, though. :)
--
Shaun Thomas
OptionsHouse | 141 W. Jackson Blvd. | Suite 500 | Chicago IL, 60604
312-676-8870
sthomas(at)optionshouse(dot)com
______________________________________________
See http://www.peak6.com/email_disclaimer/ for terms and conditions related to this email
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Dave Johansen | 2013-12-20 16:23:07 | Re: Recommendations for partitioning? |
| Previous Message | Shaun Thomas | 2013-12-20 16:11:39 | Re: slow query - will CLUSTER help? |