List:General Discussion« Previous MessageNext Message »
From:Greg Patterson Date:September 22 1999 5:01pm
Subject:Re: CPU Spikes. Slow queries.
View as plain text  
On Wed, 22 Sep 1999, Brian Moon wrote:

> select general.id, general.thread, author, subject, datestamp, body from
> general left join general_bodies on general.id = general_bodies.id where
>  datestamp > '1999-03-26' ) and (body like "%g3%" OR subject like "%g3%" OR
> author like "%g3%") order by id desc

You are losing indexing usage on the like clauses. Check for the "g3"
string in the relevant fields at the INSERT time and add a column to this
table that is a lag indicating when "g3" (or whatever) exists. You can
then index on this new flag to avoid all the extra LIKE clauses which is
slowing the query down greatly.

================================================================
|    Greg Patterson      | EMAIL: gomer@stripped        |
|                        |        gomer@stripped              |
| Linux: The choice of a | IRC:   xed (Irc.OpenProjects.Net)   |
| GNU generation!        | WWW:   http://www.linuxhelp.org/    |
================================================================

Thread
CPU Spikes. Slow queries.Brian Moon22 Sep
  • Re: CPU Spikes. Slow queries.Greg Patterson22 Sep