pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Shaun Thomas <sthomas@optionshouse.com>
To: Alvaro Herrera <alvherre@2ndquadrant.com>
To: Dave Johansen <davejohansen@gmail.com>
Cc: Scott Marlowe <scott.marlowe@gmail.com>
Cc: Jeff Janes <jeff.janes@gmail.com>
Cc: pgsql-performance <pgsql-performance@postgresql.org>
Subject: Re: Recommendations for partitioning?
Date: Fri, 20 Dec 2013 10:18:21 -0600
Message-ID: <52B46DCD.2070107@optionshouse.com> (raw)
In-Reply-To: <20131220155954.GB22570@eldon.alvh.no-ip.org>
References: <CAAcYxUemBq7mqv_-1BVPe36udVEJjDoF2_-9G4Azv7nXZtmZ3A@mail.gmail.com>
	<CAMkU=1wWcL9rzMzvsaV_OrqtexieVe16dEZvd2Q70hmB=JqLug@mail.gmail.com>
	<CAAcYxUcb0NFfMDsMOCL5scNRrUL7=9hKxjz021JMQp0r7f5sCQ@mail.gmail.com>
	<CAOR=d=3Et_2VBd9aVRtwDAiHzy+c0f0B3ur+-MfUAStMrpXsEg@mail.gmail.com>
	<CAAcYxUc_aLKkcL5cjOF5m=E34HoE4og=nbtPjVX6qoLeC9cDvg@mail.gmail.com>
	<20131220155954.GB22570@eldon.alvh.no-ip.org>
List-Unsubscribe:  <mailto:majordomo@postgresql.org?body=unsub%20pgsql-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@optionshouse.com

______________________________________________

See http://www.peak6.com/email_disclaimer/ for terms and conditions related to this email


-- 
Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance



view thread (14+ messages)  latest in thread

Message-ID: <52B46DCD.2070107@optionshouse.com>
Permalink:  ../52B46DCD.2070107@optionshouse.com/
Also on:    postgresql.org/message-id/52B46DCD.2070107@optionshouse.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: sthomas@optionshouse.com, alvherre@2ndquadrant.com, davejohansen@gmail.com, scott.marlowe@gmail.com, jeff.janes@gmail.com
  Subject: Re: Recommendations for partitioning?
  In-Reply-To: <52B46DCD.2070107@optionshouse.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox