Re: High CPU usage after partitioning

From: Merlin Moncure <mmoncure(at)gmail(dot)com>
To: rudi <rudolone(at)gmail(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: High CPU usage after partitioning
Date: 2013-01-21 17:13:31
Message-ID: CAHyXU0waVJHhQT6s5z0sCKZ5VmR0f5Ww7BhVDJsFc_u6gZSDJQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Mon, Jan 21, 2013 at 9:05 AM, rudi <rudolone(at)gmail(dot)com> wrote:
> Hello,
>
> I'm running postgresl 9.0. After partitioning a big table, CPU usage raised
> from average 5-10% to average 70-80%.
>
> - the table contains about 20.000.000 rows
> - partitions are selected using a trigger, based on an indexed field, a date
> (IF date_taken >= x AND date_taken < y)
> - I created 5 partitions, the 2012 one now contains most of the rows. The
> 2013 partition is the "live" partition, mostly insert, a few select based on
> the above indexed field. The 2013, 2014, 2015 partitions are empty
> - constraint execution is on.
>
> I have 2 weeks CPU usage reports and the pattern definately changed after I
> made the partitions. Any idea?

First thing that jumps to mind is you have some seq-scan heavy plans
that were not seq-scan before. Could be due to query fooling CE
mechanism or some other CE (probably fixable issue). To diagnose we
need to see some explain analyze plans of queries that are using
higher than expected cpu usage.

Second possible cause is trigger overhead from inserts. Not likely to
cause so much of a jump, but if this is the issue suggested
optimization path is to insert directly to the partition.

merlin

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Kevin Grittner 2013-01-21 21:12:14 Re: High CPU usage after partitioning
Previous Message Albe Laurenz 2013-01-21 16:00:07 Re: Analyze and default_statistics_target