MySQL Forums
Forum List  »  Performance

performance problem
Posted by: Babak Rafat
Date: May 03, 2012 02:58AM

Hi,
I have a fairly simple query and a base table named "customers" with around 900000 record.
when I run this query in best of it I have to wait 9 seconds to get the result and this is too much.

This is the query :

SELECT customers.item, COUNT(customers.item) AS totalqty
FROM
report_history
LEFT JOIN user ON user.id = customers.userId
LEFT JOIN usergroup ON user.usergroupId = usergroup.id
WHERE
user.id LIKE '%%'
AND
(user.userGroupId = '0' OR usergroup.level LIKE '%')
AND
buyDateTime BETWEEN '2011-01-01 00:00:00' AND '2012-05-02 23:59:59'

GROUP BY
customers.item
ORDER BY
totalqty DESC
limit 20;

Please help me to optimize this query.

Options: ReplyQuote


Subject
Views
Written By
Posted
performance problem
1599
May 03, 2012 02:58AM
1124
May 03, 2012 11:21PM
773
May 06, 2012 05:54PM


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.