Like 'name%' is not using index

From: "Jozsef Szalay" <jszalay(at)storediq(dot)com>
To: <pgsql-performance(at)postgresql(dot)org>
Subject: Like 'name%' is not using index
Date: 2006-03-03 00:15:36
Message-ID: E387E2E9622FDD408359F98BF183879E312F05@dc1.storediq.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Hi all,

I have to provide a pretty standard query that should return every row
where the NAME attribute begins with a specific string. The type of the
NAME column is varchar. I do have an index for this column. One would
think that Postgres will use the index to look up the matches, but
apparently that is not the case. It performs a full table scan. My
query looks something like this:

SELECT * FROM table WHERE name LIKE 'smith%';

Does anyone know a way to "force" the optimizer to utilize the index? Is
there perhaps another way of doing this?

Thanks for the help!

Jozsef

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Mark Kirkwood 2006-03-03 01:28:40 Re: Like 'name%' is not using index
Previous Message Jonah H. Harris 2006-03-02 18:50:24 Re: qsort again (was Re: [PERFORM] Strange Create Index behaviour)