Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 590301337B61 for ; Wed, 27 Apr 2011 23:18:55 -0300 (ADT) 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 15574-06 for ; Thu, 28 Apr 2011 02:18:48 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.17.10]) by mail.postgresql.org (Postfix) with ESMTP id B8E1F1337BD0 for ; Wed, 27 Apr 2011 23:18:47 -0300 (ADT) Received: from [192.168.1.3] (mail.highperformancepostgresql.com [71.179.240.8]) by mrelayeu.kundenserver.de (node=mreu3) with ESMTP (Nemesis) id 0MFn61-1Q3Uik2SWL-00EcDC; Thu, 28 Apr 2011 04:18:44 +0200 Message-ID: <4DB8CE7D.8030503@2ndquadrant.com> Date: Wed, 27 Apr 2011 22:18:37 -0400 From: Greg Smith User-Agent: Thunderbird 2.0.0.24 (X11/20100317) MIME-Version: 1.0 To: Joseph Shraibman CC: Robert Haas , pgsql-performance@postgresql.org Subject: Re: index usage on queries on inherited tables References: <4DB88690.5050701@selectacast.net> In-Reply-To: <4DB88690.5050701@selectacast.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:M7IqY2Gggq4eBHC8H9vGVXNGvz58V0uzTLs9J+T6x7z 6qWnGlBM28xJIiuGWdzfoD+Hrl/nmBUkidxAujydWBBtiUObRZ xKpKmnZcEBDmakLJ8DVmnfFV1UwvxAtODmZwbClNTIpbCedvGw oAbVzhnezEa7cqhtOtgQ+MfLIIzU0K25cikLIz6etVyFtE9K79 sRwDi/JRFYHTS7EiLVz1y+nH93CwC1vSrKNUV2tF8s= 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: 201104/386 X-Sequence-Number: 43448 Joseph Shraibman wrote: > In a 52 gig table I have a "select id from table limit 1 order > by id desc" returns instantly, but as soon as you declare a child table > it tries to seq scan all the tables. > This is probably the limitation that's fixed in PostgreSQL 9.1 by this commit (following a few others leading up to it): http://archives.postgresql.org/pgsql-committers/2010-11/msg00028.php There was a good example showing what didn't work as expected before (along with an earlier patch that didn't everything the larger 9.1 improvement does) at http://archives.postgresql.org/pgsql-hackers/2009-07/msg01115.php ; "ORDER BY x DESC LIMIT 1" returns the same things as MAX(x). It's a pretty serious issue with the partitioning in earlier versions. I know of multiple people, myself included, who have been compelled to apply this change to an earlier version of PostgreSQL to make larger partitioned databases work correctly. The other option is to manually decompose the queries into ones that target each of the child tables individually, then combine the results, which is no fun either. -- 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