Re: Recommendations for partitioning? - Mailing list pgsql-performance

From Alvaro Herrera
Subject Re: Recommendations for partitioning?
Date
Msg-id 20131230212907.GT22570@eldon.alvh.no-ip.org
Whole thread Raw
In response to Re: Recommendations for partitioning?  (Sergey Konoplev <gray.ru@gmail.com>)
List pgsql-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


pgsql-performance by date:

Previous
From: Sergey Konoplev
Date:
Subject: Re: Recommendations for partitioning?
Next
From: Tom Lane
Date:
Subject: Re: Performance bug in prepared statement binding in 9.2?