MySQL Forums
Forum List  »  Performance

Re: Is there a way to optimize this query?
Posted by: Sergey Petrunya
Date: January 31, 2005 10:13PM

There are two possible sources of ineficiency here:
First, are you sure the WHERE part should be (indenting the condition as it was specified in your post)
where
(
i.item_title like '%$input%' or
(c.ident_name like '%$input%' and
(c.cid = ic.cid and ic.cdid = i.cdid)
)
)
and not
where
(
(i.item_title like '%$input%' or c.ident_name like '%$input%')
and c.cid = ic.cid and ic.cdid = i.cdid
)

Second is that LIKE '%string%' causes full table scan to be performed.
Please see the thread http://forums.mysql.com/read.php?24,13397,13397#msg-13397
for possible solution.

Sergey Petrunia, Software Developer
MySQL AB, www.mysql.com
My blog: http://s.petrunia.net/blog

Options: ReplyQuote


Subject
Views
Written By
Posted
2370
January 29, 2005 12:02PM
Re: Is there a way to optimize this query?
1560
January 31, 2005 10:13PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.