Received: from maia.hub.org (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 3E550633FB9 for ; Tue, 9 Feb 2010 04:12:56 -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 96785-03 for ; Tue, 9 Feb 2010 08:12:42 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pz0-f180.google.com (mail-pz0-f180.google.com [209.85.222.180]) by mail.postgresql.org (Postfix) with ESMTP id 23F74633FFF for ; Tue, 9 Feb 2010 04:02:40 -0400 (AST) Received: by pzk10 with SMTP id 10so2994084pzk.19 for ; Tue, 09 Feb 2010 00:02:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type; bh=UcUpEuzHLXW/mnMRBFXz24BYmIBtRcfaO9ZR4YSxxQQ=; b=xC6wLXVJekRvNOPw2y4BEPNwpnB2QluT9SIxVpVn2yKmOGpr+7e3EIKksdSn4tkGPb QY+DqXu8e+ugeGA6gb0G+x4UHwOvMgof6ov7zUg92mFRRESh+gQmKYgGoHqRW5Ilv0kI hv1bNmr0jCrlBDtePxVv/JOj2Xk1cGFWMt7FE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=EYl7PfHWFxg884PdFQizwm9uerIKswyEldryi9sIetj4oV1RkUHjBKMfmwdhd50ERN 91wfFABC/tHcQP7IA6xQ7gjUODuFToqVmC9smZCgwsmU7prSFDdH1v+3dpcBOht465hQ h1qZkUlYQzJnykPr46kafF+TWtl0IuxJ3wZJk= MIME-Version: 1.0 Received: by 10.142.3.10 with SMTP id 10mr958691wfc.259.1265702149831; Mon, 08 Feb 2010 23:55:49 -0800 (PST) Date: Tue, 9 Feb 2010 13:55:49 +0600 Message-ID: <2a7905441002082355w72ec4b2br9b406f186d87c12a@mail.gmail.com> Subject: index is not using? From: AI Rumman To: pgsql-performance@postgresql.org Content-Type: multipart/alternative; boundary=0016368e270d083dbc047f263f5a X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.966 tagged_above=-10 required=5 tests=AWL=0.143, BAYES_05=-1.11, HTML_MESSAGE=0.001 X-Spam-Level: X-Archive-Number: 201002/131 X-Sequence-Number: 37552 --0016368e270d083dbc047f263f5a Content-Type: text/plain; charset=ISO-8859-1 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'; QUERY PLAN -------------------------------------------------------------------------------------------------------- Seq Scan on leadaddress (cost=100000000.00..100009699.81 rows=1 width=97) 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 creation. --0016368e270d083dbc047f263f5a Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable I have created a index
create index leadaddress_phone_idx on=A0 leadaddr= ess(regexp_replace((phone)::text, '[^0-9]*'::text, ''::text= , 'g'::text));
=A0
But the index is not using.
=A0
expl= ain 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= =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
-------= ---------------------------------------------------------------------------= ----------------------
=A0Seq Scan on leadaddress=A0 (cost=3D100000000.0= 0..100009699.81 rows=3D1 width=3D97)
=A0=A0 Filter: (regexp_replace((phone)::text, '[^0-9]*'::text, '= ;'::text, 'g'::text) ~~ '%2159438606'::text)
=A0
= Could anyone please tell me why? I analyzed the table after index creation. --0016368e270d083dbc047f263f5a--