Re: Partitioning by status? - Mailing list pgsql-performance

From Josh Berkus
Subject Re: Partitioning by status?
Date
Msg-id 4F0F2564.6030702@agliodbs.com
Whole thread Raw
In response to Partitioning by status?  (Mike Blackwell <mike.blackwell@rrd.com>)
Responses Re: Partitioning by status?
List pgsql-performance
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

pgsql-performance by date:

Previous
From: Matteo Sgalaberni
Date:
Subject: Re: partitioned table: differents plans, slow on some situations
Next
From: Tomas Vondra
Date:
Subject: wal_level=archive gives better performance than minimal - why?