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

From Scott Marlowe
Subject Re: Recommendations for partitioning?
Date
Msg-id CAOR=d=3Et_2VBd9aVRtwDAiHzy+c0f0B3ur+-MfUAStMrpXsEg@mail.gmail.com
Whole thread Raw
In response to Re: Recommendations for partitioning?  (Dave Johansen <davejohansen@gmail.com>)
Responses Re: Recommendations for partitioning?  (Dave Johansen <davejohansen@gmail.com>)
List pgsql-performance
On Thu, Dec 19, 2013 at 9:53 AM, Dave Johansen <davejohansen@gmail.com> wrote:
>>
> On Sat, Dec 7, 2013 at 1:37 PM, Scott Marlowe <scott.marlowe@gmail.com>
> wrote:
>> I'll add that you can use assymetric partitioning if you tend to do a
>> lot of more fine grained queries on recent data and more big roll up
>> on older ones. I.e. partition by month except for the last 30 days, do
>> it by day etc. Then at the end of the month roll all the days into a
>> month partition and delete them.
>
> This sounds like a great solution for us. Is there some trick to roll the
> records from one partition to another? Or is the only way just a SELECT INTO
> followed by a DELETE?

That's pretty much it. What I did was to create the new month table
and day tables, alter my triggers to reflect this, then move the data
with insert into / select from query for each old day partition. Then
once their data is moved you can just drop them. Since you changed the
triggers first those tables are no long taking input so it's usually
safe to drop them now.


pgsql-performance by date:

Previous
From: Dave Johansen
Date:
Subject: Unexpected pgbench result
Next
From: Pavel Stehule
Date:
Subject: Re: Re: Problem with slow query with WHERE conditions with OR clause on primary keys