Re: Query advice request - Mailing list pgsql-novice

From Mladen Gogala
Subject Re: Query advice request
Date
Msg-id 4CB0B337.7030208@vmsinfo.com
Whole thread Raw
In response to Query advice request  (Mark Kelly <pgsql@wastedtimes.net>)
Responses Re: Query advice request  (Mark Kelly <pgsql@wastedtimes.net>)
List pgsql-novice
Mark, you should be using text indexes. You are looking for the whole
words and the regular expression will not use an index. If you want
speed, at least one of the two columns in your query should be indexed
with a text index.

Mark Kelly wrote:
> Hi.
>
> I'm wondering if there is a better way to do this:
>
> SELECT news.id FROM news
> WHERE news.headline ~* '(japan|office)'
> OR news.body ~* '(japan|office)'
> ORDER BY news.posted DESC;
>
> It is for small articles; a few hundred or so rows in the table and not
> expecting millions.
>
> Cheers,
>
> Mark
>
>


--
Mladen Gogala
Sr. Oracle DBA
1500 Broadway
New York, NY 10036
(212) 329-5251
www.vmsinfo.com


pgsql-novice by date:

Previous
From: Mark Kelly
Date:
Subject: Query advice request
Next
From: Mladen Gogala
Date:
Subject: Re: Query advice request