Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id 75E639FB63D for ; Tue, 8 May 2007 15:41:32 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-maia, port 10024) with ESMTP id 16842-05 for ; Tue, 8 May 2007 15:41:26 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from aep-us-dc-01.aep-net.com (unknown [63.139.155.212]) by postgresql.org (Postfix) with ESMTP id 7D82F9FB7FC for ; Tue, 8 May 2007 15:41:28 -0300 (ADT) Received: from [192.168.1.31] ([192.168.1.31]) by aep-us-dc-01.aep-net.com with Microsoft SMTPSVC(5.0.2195.6713); Tue, 8 May 2007 14:41:27 -0400 Message-ID: <4640C462.2040909@aepnetworks.com> Date: Tue, 08 May 2007 14:41:38 -0400 From: Fei Liu User-Agent: Thunderbird 1.5.0.7 (X11/20060913) MIME-Version: 1.0 To: Scott Marlowe CC: Merlin Moncure , Andreas Haumer , pgsql-performance@postgresql.org Subject: Re: Query performance problems with partitioned tables References: <4635D678.3050205@xss.co.at> <4639F97D.3080003@aepnetworks.com> <1178291472.2953.47.camel@state.g2switchworks.com> In-Reply-To: <1178291472.2953.47.camel@state.g2switchworks.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 08 May 2007 18:41:28.0004 (UTC) FILETIME=[7CECD840:01C791A0] X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.658 tagged_above=0 required=5 tests=AWL=-0.670, BAYES_40=-0.185, DNS_FROM_SECURITYSAGE=1.513 X-Spam-Level: X-Archive-Number: 200705/132 X-Sequence-Number: 24522 Scott Marlowe wrote: > On Thu, 2007-05-03 at 21:37, Merlin Moncure wrote: > >> On 5/3/07, Fei Liu wrote: >> >>> Hello, Andreas, I too am having exactly the same issue as you do. >>> Comparing my partitioned and plain table performance, I've found that >>> the plain tables perform about 25% faster than partitioned table. Using >>> 'explain select ...', I see that constraints are being used so in >>> partitioned tables fewer rows are examined. But still partitioned tables >>> are 25% slower, what a let down. >>> >> That's a little bit harsh. The main use of partitioning is not to >> make the table faster but to make the maintenance easier. When >> constraint exclusion works well for a particular query you can get a >> small boost but many queries will break down in a really negative way. >> So, you are sacrificing flexibility for easier maintenance. You have >> to really be careful how you use it. >> >> The best case for partitioning is when you can logically divide up >> your data so that you really only have to deal with one sliver of it >> at a time...for joins and such. If the OP could force the constraint >> exclusion (maybe by hashing the timestamp down to a period and using >> that for where clause), his query would be fine. The problem is it's >> not always easy to do that. >> > > Agree++ > > I've been testing partitioning for a zip code lookup thing that was > posted here earlier, and I partitioned a 10,000,000 row set into about > 400 partitions. I found that selecting a range of areas defined by x/y > coordinates was faster without any indexes. The same selection with one > big table and one big (x,y) index took 3 to 10 seconds typically, same > select against the partitions with no indexes took 0.2 to 0.5 seconds. > > For that particular application, the only way to scale it was with > partitioning. > In my particular case, I have 2 million records uniformly split up in 40 partitions. It's ranged data varying with time, each partition has one month of data. Do you think this is a good candidate to seek performance boost with partitioned tables?