pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alvaro Herrera <alvherre@2ndquadrant.com>
To: Sergey Konoplev <gray.ru@gmail.com>
Cc: 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: Mon, 30 Dec 2013 18:29:07 -0300
Message-ID: <20131230212907.GT22570@eldon.alvh.no-ip.org> (raw)
In-Reply-To: <CAL_0b1v0idADRcMu9R1KW5CPzYTY4r0VzXHrGu8iY9pYrrr-cw@mail.gmail.com>
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>
	<CAL_0b1v0idADRcMu9R1KW5CPzYTY4r0VzXHrGu8iY9pYrrr-cw@mail.gmail.com>
List-Unsubscribe:  <mailto:majordomo@postgresql.org?body=unsub%20pgsql-performance>

Sergey Konoplev escribió:
> On Fri, Dec 20, 2013 at 7:59 AM, Alvaro Herrera
> <alvherre@2ndquadrant.com> wrote:

> > Eh.  Why can't you just do something like
> >
> > WITH moved AS (
> >         DELETE FROM src WHERE ..
> >         RETURNING *
> > ) INSERT INTO dst SELECT * FROM moved;
> 
> Avero, I think it could be cheaper to do this like it is shown below, correct?
> 
> psql dbname -c 'copy src to stdout' | \
> psql dbname -c 'copy dst from stdin; truncate src;'

Yes, if you can get rid of the old records by removing or emptying a
partition (or de-inheriting it, as suggested elsewhere in the thread),
that's better than DELETE because that way you don't create dead rows to
vacuum later.

-- 
Álvaro Herrera                http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services


-- 
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)

Message-ID: <20131230212907.GT22570@eldon.alvh.no-ip.org>
Permalink:  ../20131230212907.GT22570@eldon.alvh.no-ip.org/
Also on:    postgresql.org/message-id/20131230212907.GT22570@eldon.alvh.no-ip.org

 · 

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: alvherre@2ndquadrant.com, gray.ru@gmail.com, davejohansen@gmail.com, scott.marlowe@gmail.com, jeff.janes@gmail.com
  Subject: Re: Recommendations for partitioning?
  In-Reply-To: <20131230212907.GT22570@eldon.alvh.no-ip.org>

* 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