Select like when searching for whole word and optimizing it
От | Michal Samek |
---|---|
Тема | Select like when searching for whole word and optimizing it |
Дата | |
Msg-id | 375E289E.EF906BD2@tony.cz обсуждение исходный текст |
Ответы |
Re: [SQL] Select like when searching for whole word and optimizing it
Re: [SQL] Select like when searching for whole word and optimizing it -- regexp? Re: [SQL] Select like when searching for whole word and optimizing it |
Список | pgsql-sql |
In my e-shop I'm using the searching based on select like command; something like SELECT * FROM kat WHERE name LIKE '%some_text%'; and when searching for the whole word: SELECT * FROM kat WHERE name LIKE '% some_text %'; For this is necessary to maintain the name column with one space added before and after the name column value (to match starting and ending words). It's working but very ugly. Maybe there is some better way to search for the whole word? And another question, is there some way to optimize the SELECT LIKE querry? I know that when I send something like "SELECT * FROM kat WHERE name LIKE 'blabla%';" postgresql uses the index but not when the search string begins with '%'... My table is quickly growing and now I can feel the speed of my web is impacted a lot. There is a lot of same values in the name field (for ex. 'QUEEN' about 40 times etc.) - I could make a table with unique only name values and point to them from the main table kat. Will the searching be more effective then? Thanks for any help; I hope it's interesting not only for me :) -- Michal Samek, Tony distribuce s.r.o. webmaster@tony.cz (++420659/321350) ICQ: 38607210
В списке pgsql-sql по дате отправления: