pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michal Samek <webmaster@tony.cz>
To: pgsql-sql <pgsql-sql@postgresql.org>
Subject: Select like when searching for whole word and optimizing it
Date: Wed, 09 Jun 1999 10:41:02 +0200
Message-ID: <375E289E.EF906BD2@tony.cz> (raw)

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



view thread (4+ messages)  latest in thread

Message-ID: <375E289E.EF906BD2@tony.cz>
Permalink:  ../375E289E.EF906BD2@tony.cz/
Also on:    postgresql.org/message-id/375E289E.EF906BD2@tony.cz

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: webmaster@tony.cz
  Subject: Re: Select like when searching for whole word and optimizing it
  In-Reply-To: <375E289E.EF906BD2@tony.cz>
  References: <375E289E.EF906BD2@tony.cz>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox