From: | Michal Samek <webmaster(at)tony(dot)cz> |
---|---|
To: | pgsql-sql <pgsql-sql(at)postgresql(dot)org> |
Subject: | Select like when searching for whole word and optimizing it |
Date: | 1999-06-09 08:41:02 |
Message-ID: | 375E289E.EF906BD2@tony.cz |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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(at)tony(dot)cz (++420659/321350)
ICQ: 38607210
From | Date | Subject | |
---|---|---|---|
Next Message | Nuchanard Chiannilkulchai | 1999-06-09 08:47:25 | automatic incrementation |
Previous Message | Michael Klemme | 1999-06-09 08:28:30 | SQL Problem: ERROR: ExecEvalExpr: unknown expression type 108 |