Like 'name%' is not using index

Поиск
Список
Период
Сортировка
От Jozsef Szalay
Тема Like 'name%' is not using index
Дата
Msg-id E387E2E9622FDD408359F98BF183879E312F05@dc1.storediq.com
обсуждение исходный текст
Ответы Re: Like 'name%' is not using index  (Mark Kirkwood <markir@paradise.net.nz>)
Re: Like 'name%' is not using index  (Greg Stark <gsstark@mit.edu>)
Список 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

В списке pgsql-performance по дате отправления:

Предыдущее
От: Bruce Momjian
Дата:
Сообщение: Re: [HACKERS] qsort again (was Re: Strange Create Index behaviour)
Следующее
От: Mark Kirkwood
Дата:
Сообщение: Re: Like 'name%' is not using index