Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 3F80E9FBC4F for ; Fri, 30 Mar 2007 10:37:06 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 37851-04 for ; Fri, 30 Mar 2007 10:36:49 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from mail.beccati.com (ispeed3.vps.tomato.it [213.92.0.39]) by postgresql.org (Postfix) with SMTP id 592F59FB69B for ; Fri, 30 Mar 2007 10:36:48 -0300 (ADT) Received: (qmail 40272 invoked from network); 30 Mar 2007 13:36:43 -0000 Received: from unknown (HELO ?192.168.1.201?) (matteo@beccati.com@88.149.176.119) by mail.beccati.com with SMTP; 30 Mar 2007 13:36:43 -0000 Message-ID: <460D125A.4030101@beccati.com> Date: Fri, 30 Mar 2007 15:36:26 +0200 From: Matteo Beccati User-Agent: Mozilla Thunderbird 1.5.0.10 (Windows/20070221) MIME-Version: 1.0 To: Gaetano Mendola CC: "pgsql-performance@postgresql.org" , Michael Fuhr Subject: Re: Wrong plan sequential scan instead of an index one References: <460CD941.6080303@bigfoot.com> <460CE19A.3060909@bigfoot.com> <20070330104611.GA1540@winnie.fuhr.org> <20070330105534.GA1737@winnie.fuhr.org> <460CF5E4.3090005@bigfoot.com> In-Reply-To: <460CF5E4.3090005@bigfoot.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.196 tagged_above=0 required=5 tests=AWL=0.061, BAYES_50=0.001, FORGED_RCVD_HELO=0.135, SPF_PASS=-0.001 X-Spam-Level: X-Archive-Number: 200703/449 X-Sequence-Number: 23854 Gaetano Mendola wrote: > Michael Fuhr wrote: >> On Fri, Mar 30, 2007 at 04:46:11AM -0600, Michael Fuhr wrote: >>> Have you tried increasing the statistics target on l_pvcp.value? >>> I ran your queries against canned data in 8.2.3 and better statistics >>> resulted in more accurate row count estimates for this and other >>> parts of the plan. I don't recall if estimates for non-leading-character >>> matches in earlier versions can benefit from better statistics. >> This might work only in 8.2. I see the following in the Release Notes: >> >> * Improve the optimizer's selectivity estimates for LIKE, ILIKE, >> and regular expression operations (Tom) > > > I will try same select on a 8.2 ( that one was a 8.1 ) and I'll let you > know. You will also need to set statistics for the column to at least 100 to trigger the improved selectivity estimate if memory serves. Not enough time to check the code, but Tom could better advise. Best regards -- Matteo Beccati http://phpadsnew.com http://phppgads.com