Like 'name%' is not using index

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


[Postgresql General]     [Postgresql PHP]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Yosemite]

  Powered by Linux