I have the following query and its causing the mysql server to run really slowly i would like it if someone could help me optimise it or the table well this is the query SELECT T.tag, COUNT(T.bId) AS bCount FROM sc_bookmarks2tags AS T, sc_bookmarks AS B WHERE B.bId = T.bId AND B.bStatus = 0 GROUP BY T.tag ORDER BY bCount DESC, tag Code (markup):
it may be possible to speed up the query execution, but we would need to know more about the setup of your database. can you post the schema please
Run this in phpmyadmin: EXPLAIN SELECT T.tag, COUNT(T.bId) AS bCount FROM sc_bookmarks2tags AS T, sc_bookmarks AS B WHERE B.bId = T.bId AND B.bStatus = 0 GROUP BY T.tag ORDER BY bCount DESC, tag Code (markup): And post the results (or a screenshot)
The problem is that you are ordering by the COUNT, which cannot be indexed. Probably not much you can do to speed this up as is.