Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id E2E5A9FBE35 for ; Fri, 30 Mar 2007 08:48:23 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-maia, port 10024) with ESMTP id 47555-10 for ; Fri, 30 Mar 2007 08:48:15 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from mail.metronet.co.uk (mail.metronet.co.uk [213.162.97.75]) by postgresql.org (Postfix) with ESMTP id 6E0319FBDF7 for ; Fri, 30 Mar 2007 08:48:20 -0300 (ADT) Received: from server3.office.archonet.com (84-51-143-99.archon037.adsl.metronet.co.uk [84.51.143.99]) by smtp.metronet.co.uk (MetroNet Mail) with ESMTP id 4E523144582; Fri, 30 Mar 2007 12:48:19 +0100 (BST) Received: from [192.168.1.36] (dell36.office.archonet.com [192.168.1.36]) by server3.office.archonet.com (Postfix) with ESMTP id 2B70427408E; Fri, 30 Mar 2007 12:48:19 +0100 (BST) Message-ID: <460CF902.4020707@archonet.com> Date: Fri, 30 Mar 2007 12:48:18 +0100 From: Richard Huxton User-Agent: IceDove 1.5.0.9 (X11/20061220) MIME-Version: 1.0 To: Gaetano Mendola Cc: "pgsql-performance@postgresql.org" Subject: Re: Wrong plan sequential scan instead of an index one References: <460CD941.6080303@bigfoot.com> <460CDCDC.7020901@archonet.com> <460CE359.8060208@bigfoot.com> <460CE775.8080908@archonet.com> <460CF40F.6060303@mbigroup.it> In-Reply-To: <460CF40F.6060303@mbigroup.it> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200703/447 X-Sequence-Number: 23852 Gaetano Mendola wrote: > > The match 19 for '%pi%' is estimated, the real matches are: > > test=# select id from l_pvcp where value ilike '%pi%'; > id > - ---- > 62 > (1 row) > > > test=# select id from l_pvcp where value ilike 'pi'; > id > - ---- > 62 > (1 row) > > so one row in both cases, that's why I expect for both same plan. Ah, but it's got no way of knowing what matches you'll get for '%anything%'. There's no easy way to get statistics for matching substrings. -- Richard Huxton Archonet Ltd