My CPU was running at a constant 99.8%
A look in /var/log/mysql-slow-query.log
showed the query:
-----------------------------QUERY------------------------------------
SELECT * , COUNT( a_inbox.id ) AS numInInbox
FROM a_searchA
LEFT OUTER JOIN a_inbox ON a_searchA.userid = a_inbox.userid
WHERE active = '1'
GROUP BY a_searchA.userid;
-----------------------------QUERY------------------------------------
When I ran the query from phpmyadmin, it returned no result after 5 minutes. So I killed the process.
The query (note the "EXPLAIN"):
-----------------------------QUERY------------------------------------
EXPLAIN SELECT * , COUNT( a_inbox.id ) AS numInInbox
FROM a_searchA
LEFT OUTER JOIN a_inbox ON a_searchA.userid = a_inbox.userid
WHERE active = '1'
GROUP BY a_searchA.userid;
-----------------------------QUERY------------------------------------
produced this result:
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE a_searchA ALL NULL NULL NULL NULL 18798 Using where; Using temporary; Using filesort
1 SIMPLE a_inbox ALL NULL NULL NULL NULL 35403
Also,
a_searchA has 18,798 records
a_inbox has 35,401 records
I'd appreciate suggestions on how to fix the query.
Thank you.