Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 8045A6324AA for ; Sat, 24 Jul 2010 02:12:44 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 88190-06 for ; Sat, 24 Jul 2010 05:12:32 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.126.187]) by mail.postgresql.org (Postfix) with ESMTP id 476D863231A for ; Sat, 24 Jul 2010 02:12:32 -0300 (ADT) Received: from [192.168.1.5] (static-71-179-240-8.bltmmd.fios.verizon.net [71.179.240.8]) by mrelayeu.kundenserver.de (node=mreu1) with ESMTP (Nemesis) id 0LsdeH-1P139r0QZ7-012kBG; Sat, 24 Jul 2010 07:12:30 +0200 Message-ID: <4C4A763C.8090701@2ndquadrant.com> Date: Sat, 24 Jul 2010 01:12:28 -0400 From: Greg Smith User-Agent: Thunderbird 2.0.0.24 (X11/20100317) MIME-Version: 1.0 To: gvfontenay@lbl.gov CC: pgsql-performance@postgresql.org Subject: Re: Strange explain on partitioned tables References: <4C47F8C8.10005@edd.fr> <4C484874.3060609@2ndquadrant.com> <4C4A11CB.6040800@lbl.gov> In-Reply-To: <4C4A11CB.6040800@lbl.gov> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:BPUC563e1a5fi2taI5KtSUkAsoJ6ymJpUX0r0B5YQLa WwpBatJgdoW44J9Jd44XwCHcxNXj6CeHfd0H9eKW/iT4qo1Ga/ h6fxy8j4aC5ll4a2lCfL/rtutAIur9opLwJaHumHJU1kSXcJv+ 9ib7ebzwHRYRM5KlD1RTfGDrJgFRjV+BDnIF1Cgv7e2E+mspf+ o5ew+tWtB4sMRVrpdtx+FxGCwYahI2aMJm73bg9aLk= X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.8 tagged_above=-10 required=5 tests=BAYES_50=0.8, RCVD_IN_DNSWL_NONE=-0.0001 X-Spam-Level: X-Archive-Number: 201007/343 X-Sequence-Number: 39732 Gerald Fontenay wrote: > >> The PostgreSQL partitioning system is aimed to support perhaps a >> hundred inherited tables. You can expect to get poor performance on >> queries if you create 1000 of them. > > Why is that you would expect poor performance for say 1000 or more? When the query planner executes, it has to scan through every child table to run the constraint exclusion algorithm for determining whether that table needs to be included in the query results or not. The time that takes is proportional to the number of partitions. If your queries take a long time to execute relative to how long they take to plan, you may not have noticed this. But for shorter queries, and ones where there are lots of joins that require many plans be evaluated, the planning overhead increase can be significant. The threshold for where it becomes painful is obviously workload dependent, but the thing to be careful of is that supporting very large numbers of partitions is not something that the database query planner has been optimized for yet. -- Greg Smith 2ndQuadrant US Baltimore, MD PostgreSQL Training, Services and Support greg@2ndQuadrant.com www.2ndQuadrant.us