index is not using

Started by AI Rummanabout 16 years ago3 messagesgeneral
Jump to latest
#1AI Rumman
rummandba@gmail.com

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.

#2Guillaume Lelarge
guillaume@lelarge.info
In reply to: AI Rumman (#1)
Re: index is not using

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

#3Scott Marlowe
scott.marlowe@gmail.com
In reply to: AI Rumman (#1)
Re: index is not using

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 <rummandba@gmail.com> 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';
                                               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.

--
When fascism comes to America, it will be intolerance sold as diversity.