Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 40EB5650115 for ; Thu, 7 Aug 2008 20:05:04 -0300 (ADT) Received: from postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 63653-07 for ; Thu, 7 Aug 2008 20:04:56 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from fg-out-1718.google.com (fg-out-1718.google.com [72.14.220.152]) by postgresql.org (Postfix) with ESMTP id A198F650010 for ; Thu, 7 Aug 2008 20:05:00 -0300 (ADT) Received: by fg-out-1718.google.com with SMTP id 16so546132fgg.23 for ; Thu, 07 Aug 2008 16:04:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:cc:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=hPSQe2a1BY6lkHUoEU+Ri7D1jeT2Do6hsLAqP7fv6As=; b=xEf3mJFYEI2BBBKJsiwrTTTVlWdaHFI/McZRNHLMo20DwSC0xaNqT+ktTAlqeiJszL hOzavy4eoN0oJI+7EnN6NDElIbOdAS3a8JIVg/0kZi4Yt2rzw2uZVVm5rsXq3hkIK+IC zvZwVngkQb5NoFoXZeVU7kiiYfrZPw3DgR9d0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=t6aPhOHBCC4RBIj3FAfnfW7D2yiVp/hyjDQMZBou6FiiVbcG+t8YPJK8CDTyQyRp7e 9rltb5iXBsG2DM70VkW+zIhA6L8TrRvzbdE7Q7Mggm+2cLmRB3quzaPreBWz2mRIDtPO 2le3ZzNxtLkWoAY7fxP3tmiDGYAYiSbeDAV2g= Received: by 10.86.26.11 with SMTP id 11mr2158930fgz.71.1218150298955; Thu, 07 Aug 2008 16:04:58 -0700 (PDT) Received: by 10.86.2.11 with HTTP; Thu, 7 Aug 2008 16:04:58 -0700 (PDT) Message-ID: <84f0acdb0808071604j73992accp1f770c4c7deec5d9@mail.gmail.com> Date: Thu, 7 Aug 2008 18:04:58 -0500 From: "Joshua Shanks" To: "Gregory Stark" Subject: Re: query planner not using the correct index Cc: "Tom Lane" , "Craig Ringer" , pgsql-performance@postgresql.org In-Reply-To: <874p5wsb74.fsf@oxford.xeocode.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <84f0acdb0808061435q5ebb607cjc311f1eb4da841a@mail.gmail.com> <489A623A.4090400@postnewspapers.com.au> <84f0acdb0808062014p29cf7482ied332225a0a92c63@mail.gmail.com> <489A6AF5.50908@postnewspapers.com.au> <84f0acdb0808070811l43a3da9eq240d272f8ddd105c@mail.gmail.com> <27696.1218143560@sss.pgh.pa.us> <84f0acdb0808071501n15b0182ga7eca7b1be37d705@mail.gmail.com> <874p5wsb74.fsf@oxford.xeocode.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200808/61 X-Sequence-Number: 30942 On Thu, Aug 7, 2008 at 5:38 PM, Gregory Stark wrote: > Measuring n_distinct from a sample is inherently difficult and unreliable. > When 98% of your table falls into those categories it's leaving very few > chances for the sample to find many other distinct values. > > I haven't seen the whole thread, if you haven't tried already you could try > raising the statistics target for these columns -- that's usually necessary > anyways when you have a very skewed distribution like this. > I did some tweaking on default_statistics_target earlier in the thread with no luck. I just retried it with default_statistics_target set to 500 and did the VACUUM ANALYZE on the other table this time and started to see better results and more of the behavior I would expect. Is there a way to set the stats target for just one column? That seems like what we might need to do. > Yeah, Heikki's suggested having a kind of "branch" plan node that knows how > where the break-point is between two plans and can call the appropriate one. > We don't have anything like that yet. > Is this already on a todo list or is there a bug for it?