Re: index is not using

From: Guillaume Lelarge <guillaume(at)lelarge(dot)info>
To: AI Rumman <rummandba(at)gmail(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org, pgsql-general(at)postgresql(dot)org
Subject: Re: index is not using
Date: 2010-02-09 09:34:04
Message-ID: 4B712C0C.6040906@lelarge.info
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-performance

Le 09/02/2010 08:43, AI Rumman a écrit :
> 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.
>

The index cannot be used if the filter is '%something' or
'%somethingelse%'. I can only be used for 'this%'.

--
Guillaume.
http://www.postgresqlfr.org
http://dalibo.com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Scott Marlowe 2010-02-09 09:43:58 Re: index is not using
Previous Message Scott Marlowe 2010-02-09 09:19:13 Re: Order by and strings

Browse pgsql-performance by date

  From Date Subject
Next Message Scott Marlowe 2010-02-09 09:43:58 Re: index is not using
Previous Message Scott Marlowe 2010-02-09 08:33:13 Re: index is not using?