Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 10E841337BA5 for ; Mon, 28 Feb 2011 08:58:01 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 05697-05 for ; Mon, 28 Feb 2011 12:57:53 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from exprod7og109.obsmtp.com (exprod7og109.obsmtp.com [64.18.2.171]) by mail.postgresql.org (Postfix) with ESMTP id 36C821337B8D for ; Mon, 28 Feb 2011 08:57:53 -0400 (AST) Received: from source ([74.125.82.42]) (using TLSv1) by exprod7ob109.postini.com ([64.18.6.12]) with SMTP ID DSNKTWub0AQrz03oPg8TCRkUAaq0Bgf+l7l+@postini.com; Mon, 28 Feb 2011 04:57:54 PST Received: by mail-ww0-f42.google.com with SMTP id 15so3066888wwe.1 for ; Mon, 28 Feb 2011 04:57:52 -0800 (PST) Received: by 10.216.56.65 with SMTP id l43mr2171009wec.113.1298897872571; Mon, 28 Feb 2011 04:57:52 -0800 (PST) Received: from [192.168.1.183] (dsl-hkibrasgw2-ff7ac300-240.dhcp.inet.fi [88.195.122.240]) by mx.google.com with ESMTPS id s50sm1858746weh.46.2011.02.28.04.57.50 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 28 Feb 2011 04:57:51 -0800 (PST) Message-ID: <4D6B9BC9.1000404@enterprisedb.com> Date: Mon, 28 Feb 2011 14:57:45 +0200 From: Heikki Linnakangas User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; fi-FI; rv:1.9.1.16) Gecko/20101226 Icedove/3.0.11 MIME-Version: 1.0 To: Marc Cousin CC: pgsql-performance@postgresql.org Subject: Re: inheritance: planning time vs children number vs column number References: <201102281038.04945.cousinmarc@gmail.com> In-Reply-To: <201102281038.04945.cousinmarc@gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-4.2 tagged_above=-10 required=5 tests=BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3 X-Spam-Level: X-Archive-Number: 201102/525 X-Sequence-Number: 42663 On 28.02.2011 11:38, Marc Cousin wrote: > I've been facing a very large (more than 15 seconds) planning time in a > partitioned configuration. The amount of partitions wasn't completely crazy, > around 500, not in the thousands. The problem was that there were nearly 1000 > columns in the parent table (very special use case, there is a reason for this > application for having these many columns). The check constraint was extremely > simple (for each child, 1 column = 1 constant, always the same column). > > As I was surprised by this very large planning time, I have been trying to > study the variation of planning time against several parameters: > - number of columns > - number of children tables > - constraint exclusion's value (partition or off) > > What (I think) I measured is that the planning time seems to be O(n^2) for the > number of columns, and O(n^2) for the number of children tables. > > Constraint exclusion had a limited impact on planning time (it added between > 20% and 100% planning time when there were many columns). Testing here with a table with 1000 columns and 100 partitions, about 80% of the planning time is looking up the statistics on attribute width, to calculate average tuple width. I don't see O(n^2) behavior, though, it seems linear. > I'd like to know if this is a known behavior ? And if I could mitigate it > somehow ? I'm out of ideas on how to make it faster, I'm afraid. -- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com