Received: from ns.silesnet.cz (IDENT:root@ns.silesnet.cz [194.228.108.19]) by hub.org (8.9.3/8.9.3) with ESMTP id EAA86473 for ; Wed, 9 Jun 1999 04:43:31 -0400 (EDT) (envelope-from webmaster@tony.cz) Received: from tony.cz (ct2.silesnet.cz [194.228.108.2]) by ns.silesnet.cz (8.8.7/8.8.7) with ESMTP id KAA04537 for ; Wed, 9 Jun 1999 10:43:24 +0200 Sender: root@ns.silesnet.cz Message-ID: <375E289E.EF906BD2@tony.cz> Date: Wed, 09 Jun 1999 10:41:02 +0200 From: Michal Samek X-Mailer: Mozilla 4.06 [en] (X11; I; Linux 2.2.5 i686) MIME-Version: 1.0 To: pgsql-sql Subject: Select like when searching for whole word and optimizing it Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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