| From: | Josh Berkus <josh(at)agliodbs(dot)com> | 
|---|---|
| To: | pgsql-performance(at)postgresql(dot)org | 
| Subject: | Re: Partitioning by status? | 
| Date: | 2012-01-12 18:24:36 | 
| Message-ID: | 4F0F2564.6030702@agliodbs.com | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | 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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tomas Vondra | 2012-01-12 23:17:22 | wal_level=archive gives better performance than minimal - why? | 
| Previous Message | Matteo Sgalaberni | 2012-01-11 11:57:42 | Re: partitioned table: differents plans, slow on some situations |