pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Josh Berkus <josh@agliodbs.com>
To: pgsql-performance@postgresql.org
Subject: Re: Partitioning by status?
Date: Thu, 12 Jan 2012 10:24:36 -0800
Message-ID: <4F0F2564.6030702@agliodbs.com> (raw)
In-Reply-To: <CANPAkgt9mGoF7SyA_n7jX3t6siLGPyA=d1tR2bPwKiAex3bDMQ@mail.gmail.com>
References: <CANPAkgt9mGoF7SyA_n7jX3t6siLGPyA=d1tR2bPwKiAex3bDMQ@mail.gmail.com>

Mike,

> Is it practical to partition on the status column and, eg, use triggers to
> move a row between the two partitions when status is updated?  Any
> surprises to watch for, given the status column is actually NULL for active
> data and contains a value when archived?

When I've done this before, I've had a setup like the following:

1. One "active" partition

2. Multiple "archive" partitions, also partitioned by time (month or year)

3. stored procedure for archiving a record or records.

I'd recommend against triggers because they'll be extremely inefficient
if you need to archive a large number of rows at once.

Also, (2) only really works if you're going to obsolesce (remove)
archive records after a certain period of time.  Otherwise the
sub-partitioning hurts performance.

-- 
Josh Berkus
PostgreSQL Experts Inc.
http://pgexperts.com



view thread (6+ messages)  latest in thread

Message-ID: <4F0F2564.6030702@agliodbs.com>
Permalink:  ../4F0F2564.6030702@agliodbs.com/
Also on:    postgresql.org/message-id/4F0F2564.6030702@agliodbs.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: josh@agliodbs.com
  Subject: Re: Partitioning by status?
  In-Reply-To: <4F0F2564.6030702@agliodbs.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