Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 770FDB6272F for ; Wed, 1 Jun 2011 07:23:37 -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 43641-07 for ; Wed, 1 Jun 2011 10:23:30 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.126.171]) by mail.postgresql.org (Postfix) with ESMTP id 32B46B6270E for ; Wed, 1 Jun 2011 07:23:30 -0300 (ADT) Received: from [192.168.1.6] (mail.highperformancepostgresql.com [71.179.240.8]) by mrelayeu.kundenserver.de (node=mrbap0) with ESMTP (Nemesis) id 0LwGC6-1PXJ4p1FFe-017MQR; Wed, 01 Jun 2011 12:23:29 +0200 Message-ID: <4DE61320.6070104@2ndQuadrant.com> Date: Wed, 01 Jun 2011 06:23:28 -0400 From: Greg Smith User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.16) Gecko/20110505 Icedove/3.0.11 MIME-Version: 1.0 To: pgsql-admin@postgresql.org Subject: Re: Strange behavior of child table. References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Provags-ID: V02:K0:czQtM462Mo0muXlHQNeqiQuhb6dnYgVTS4vroZmUPtT PJgMnTkdZQww1twuRgehBAJkWfWZNqeLJE4PKPiS6GHFXUNYFn 0WdNsuQPhKH6GUUjBd42Fm7CsP14nRemD13I8Zj0L+wVKmezeX Lmy3QRkXpDw2RTXOrck1a/tKiJm5XoxfFLPHvIaJhSxlOfsdSg 7WSNyzPz+VUqWVCCjxOcm3L95UHJCWNMB1sEg035DQ= X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-10 required=5 tests=BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001 X-Spam-Level: X-Archive-Number: 201106/2 X-Sequence-Number: 37628 On 06/01/2011 02:07 AM, Jenish wrote: > select * from Round_Action where action_id =50000 limit 100 → > execution time 80 sec > > select * from Round_Action_CH1 action_id =50000 limit 100 → execution > time 0.1 sec > > First off: each of the child tables needs to have the index created on them. That doesn't get inherited just by putting it on the master. If you already did that, try running these both with "EXPLAIN". Sharing the two query plans here would help figure out what's happening. Showing the definition of the index on one of the child tables would be helpful too. There are some optimizer limitations in PostgreSQL versions before 9.0 that prevent it from using an index on the child tables in some situations where people expect it to, which includes aggregates like MIN/MIN. I'm not sure if your LIMIT case is running into the same issue, the plan will help confirm what's going on. -- Greg Smith 2ndQuadrant US greg@2ndQuadrant.com Baltimore, MD PostgreSQL Training, Services, and 24x7 Support www.2ndQuadrant.us "PostgreSQL 9.0 High Performance": http://www.2ndQuadrant.com/books