Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id B85E81337B80 for ; Wed, 27 Apr 2011 18:42: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 10038-04 for ; Wed, 27 Apr 2011 21:42:48 +0000 (UTC) X-Greylist: delayed 00:30:58.420154 by SQLgrey-1.7.6 Received: from corp1.xtenit.com (corp1.xtenit.com [63.240.50.214]) by mail.postgresql.org (Postfix) with ESMTP id 774A11337BB7 for ; Wed, 27 Apr 2011 18:42:48 -0300 (ADT) Received: from tupari.net (h-66-166-198-124.nycmny83.static.covad.net [66.166.198.124]) by corp1.xtenit.com (8.13.8/8.13.8) with ESMTP id p3RLBk1l022984 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 27 Apr 2011 17:11:46 -0400 Received: from jks-desktop.tupari.net (jks-desktop.tupari.net [192.168.1.3]) (authenticated bits=0) by tupari.net (8.14.2/8.14.1) with ESMTP id p3RLBiWK030664 (version=TLSv1/SSLv3 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Wed, 27 Apr 2011 17:11:45 -0400 Message-ID: <4DB88690.5050701@selectacast.net> Date: Wed, 27 Apr 2011 17:11:44 -0400 From: Joseph Shraibman User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.15) Gecko/20110307 Fedora/3.1.9-0.38.b3pre.fc13 Thunderbird/3.1.9 MIME-Version: 1.0 To: Robert Haas CC: pgsql-performance@postgresql.org Subject: Re: index usage on queries on inherited tables References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Received-SPF: Pass (client IP white listed); receiver=corp1.xtenit.com; client-ip=66.166.198.124; envelope-from= Received-SPF: Pass (client IP white listed); receiver=corp1.xtenit.com; client-ip=66.166.198.124; helo= Received-SPF: Pass (sender authenticated); receiver=tupari.net; client-ip=192.168.1.3; envelope-from= Received-SPF: Pass (sender authenticated); receiver=tupari.net; client-ip=192.168.1.3; helo= 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 X-Spam-Level: X-Archive-Number: 201104/382 X-Sequence-Number: 43444 On 04/27/2011 04:32 PM, Robert Haas wrote: > In the first case, PostgreSQL evidently thinks that using the indexes > will be slower than just ignoring them. You could find out whether > it's right by trying it with enable_seqscan=off. My point is that this is just a problem with inherited tables. It should be obvious to postgres that few rows are being returned, but in the inherited tables case it doesn't use indexes. This was just an example. 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.