Optimizing a query with group by and order by count
Hi,
I've a table which has millions of records
the table has cat columin which is varchar(250) NOT NULl and has index
i'm trying to optimize this query
SELECT `SIC`, COUNT(`SIC`) as total FROM `listing` GROUP BY `SIC` HAVING `total` > 1 ORDER BY `total` DESC LIMIT 0, 200
it takes about 2.5 secs to execute and uses index, temporary tbl and filesort but without the order by statement it only takes about 0.05 sec only using index
now could you please suggest me what should i do to get the least execution time with the order by statement.
Thank you very much for your time.
Subject
Views
Written By
Posted
Optimizing a query with group by and order by count
8971
March 20, 2011 01:32AM
2854
March 21, 2011 10:08AM
3214
March 21, 2011 10:32PM
2686
March 22, 2011 07:41PM
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.