Re: Monthly table partitioning for fast purges?

From: "Shridhar Daithankar" <shridhar_daithankar(at)persistent(dot)co(dot)in>
To: <pgsql-general(at)postgresql(dot)org>
Subject: Re: Monthly table partitioning for fast purges?
Date: 2003-08-03 11:31:28
Message-ID: 3F2D3FE8.2497.1F0F5206@localhost
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 1 Aug 2003 at 13:46, Roger Hand wrote:
> In Oracle you can divide a table into partitions. We use this feature to break up the data by month. Each month we store several tens of millions of rows in a particular table, and each month we drop the partition that's a year old. In other words, we always keep the last 12 months of data (12 partitions). This is clean and fast. Since the partition is by a timestamp column, it also gives us a certain amount of automatic indexing.
>
> Postgres doesn't support table partitions (correct me if I'm wrong!) so the only option appears to be to dump everything into one big table. What I'm worried about is the purging of the data from 12 months ago ... I'm worried that this will be a slow and expensive operation.

Well, you need to emulate this feature on postgresql, as pointed out already.
It is possible in postgresql but is not provided out of the box.

Here is what you can do.

* Create a empty base table.
* Create a trigger the directs the select on timestamps accordingly
* Write a schedule to create a new table at the start of every month and update
the trigger accordingly
* Create and maintain rules to insert into base table depending upon the
timestamp.

This is just a rough idea.

There might be fair amount of work to get this working but surely it is not
imposible.

HTH

Bye
Shridhar

--
Justice, n.: A decision in your favor.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Francisco Figueiredo Jr. 2003-08-03 14:01:24 Re: Is there support for output parameters?
Previous Message Jason Godden 2003-08-03 11:08:36 Re: COPY and double-quote-separated fields