Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id C604F1337BF7 for ; Fri, 29 Apr 2011 19:53:24 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 27754-08 for ; Fri, 29 Apr 2011 22:53:07 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-bw0-f46.google.com (mail-bw0-f46.google.com [209.85.214.46]) by mail.postgresql.org (Postfix) with ESMTP id 747561337990 for ; Fri, 29 Apr 2011 19:53:05 -0300 (ADT) Received: by bwz15 with SMTP id 15so3445200bwz.19 for ; Fri, 29 Apr 2011 15:53:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:references:in-reply-to:mime-version :content-transfer-encoding:content-type:message-id:cc:x-mailer:from :subject:date:to; bh=ACB4AOPlTNV9rp9fv1gY6Y7JpsiEWJxdG392J6S0xYU=; b=FXV5nv/tbZOllrZkCOgcaqaMwKxXVuYb0i2qSBpzaZaemmxPWAyNVKWEipqXDgJ17m zSLK96+GOVToaGqZWrH+j9yjLtYHfAllhyp4bO/tt01SQuG2armxtFTqw79WKdNsi1tl NcFe2B4Ge4YI3jV283nMf93oubLyavl+ftIf0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=references:in-reply-to:mime-version:content-transfer-encoding :content-type:message-id:cc:x-mailer:from:subject:date:to; b=Q3xO7CYVeh1dV0r4SFdHmaHORkgU59b5Rzv2IsPg8KiUWs//qnfffY32Rhx1+ItljB BDgtqHgbyTLiTKoBvTwDjVbbGy2pOnDVT6iLjerCXM6Ax31EX7nCX9bIKP6FrBjW5PHG 9cJzi+9BmopeJICHXKKh3GPZDiOt/JU6OsxEY= Received: by 10.204.20.143 with SMTP id f15mr933663bkb.173.1304117585635; Fri, 29 Apr 2011 15:53:05 -0700 (PDT) Received: from [192.168.2.143] (p5498AC0B.dip.t-dialin.net [84.152.172.11]) by mx.google.com with ESMTPS id u15sm1870078bkf.4.2011.04.29.15.53.00 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 29 Apr 2011 15:53:04 -0700 (PDT) References: <4DB88690.5050701@selectacast.net> In-Reply-To: <4DB88690.5050701@selectacast.net> Mime-Version: 1.0 (iPhone Mail 8A293) Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii Message-Id: Cc: "pgsql-performance@postgresql.org" X-Mailer: iPhone Mail (8A293) From: Robert Haas Subject: Re: index usage on queries on inherited tables Date: Sat, 30 Apr 2011 00:53:48 +0200 To: Joseph Shraibman X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.898 tagged_above=-10 required=5 tests=BAYES_00=-1.9, FREEMAIL_FROM=0.001, RFC_ABUSE_POST=0.001 X-Spam-Level: X-Archive-Number: 201104/427 X-Sequence-Number: 43489 On Apr 27, 2011, at 11:11 PM, Joseph Shraibman wrote: > 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. Oh, sorry, I must have misunderstood. As Greg says, this is fixed in 9.1. ...Robert