Received: from maia.hub.org (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id C5B5E632E3D for ; Tue, 9 Feb 2010 05:50:25 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 18321-03 for ; Tue, 9 Feb 2010 09:50:20 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-ew0-f222.google.com (mail-ew0-f222.google.com [209.85.219.222]) by mail.postgresql.org (Postfix) with ESMTP id 17395632E12 for ; Tue, 9 Feb 2010 05:50:24 -0400 (AST) Received: by ewy22 with SMTP id 22so448858ewy.34 for ; Tue, 09 Feb 2010 01:50:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=e9FGMTiGpym3XigDDRw5lXyBG4abpx9OFv89EAgIBHo=; b=RNswX/Ka/2tM2WNwHrMK6wKja31ZH+bxasb7gcABVO3ui3wAjwpQNmBHu3SWVXNJKf vaPV0MA9//2lDnPyDtBhT0ODur9WxJPFOu/0RTlRaclTCP3USLbAmm7IlMnwqSoC7EbA nVSvAMCFfXJPSlwvFSD7IaKzGlXHqQGS+pxiU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=FQsMKUdnaXPR4wXuFewIVe7I4nEnE9J6ZPFPO08FmbCcjEtCpgc5kZAzNBbf0HnCH9 74xEI1ALCVJGVZnvVpPJQvdig4NP1MSCr3hJSE5WpW8P5g363glX7+A0CfjV4MSGad9O MM9fZkhu7nm+gcfd7962ZNFrwlT63eBYKVNAs= MIME-Version: 1.0 Received: by 10.216.86.193 with SMTP id w43mr2567510wee.16.1265708638404; Tue, 09 Feb 2010 01:43:58 -0800 (PST) In-Reply-To: <2a7905441002082343g1dd0c8ebg5a27f7d44ec9fdb1@mail.gmail.com> References: <2a7905441002082343g1dd0c8ebg5a27f7d44ec9fdb1@mail.gmail.com> Date: Tue, 9 Feb 2010 02:43:58 -0700 Message-ID: Subject: Re: index is not using From: Scott Marlowe To: AI Rumman Cc: pgsql-performance@postgresql.org, pgsql-general@postgresql.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.37 tagged_above=-10 required=5 tests=AWL=0.229, BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 201002/327 X-Sequence-Number: 159103 I just answered this less than an hour ago... And please don't cross post to multiple mailing lists. On Tue, Feb 9, 2010 at 12:43 AM, AI Rumman wrote: > I have created a index > create index leadaddress_phone_idx on > leadaddress(regexp_replace((phone)::text, '[^0-9]*'::text, ''::text, > 'g'::text)); > > But the index is not using. > > explain select * from leadaddress where > regexp_replace(phone,'[^0-9]*','','g') like '%2159438606'; > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 QUERY > PLAN > -------------------------------------------------------------------------= ------------------------------- > =A0Seq Scan on leadaddress=A0 (cost=3D100000000.00..100009699.81 rows=3D1= width=3D97) > =A0=A0 Filter: (regexp_replace((phone)::text, '[^0-9]*'::text, ''::text, > 'g'::text) ~~ '%2159438606'::text) > > Could anyone please tell me why? I analyzed the table after index creatio= n. > --=20 When fascism comes to America, it will be intolerance sold as diversity.