mysql count group by order by optimization
问题 I have a table to store tag name for posts table: tagname tags | pid festival | 10034 New York Fashion Week | 10034 festival | 10035 car | 10036 ... The table now has already 590,000 records. Now I want to get the first 10 most popular tags from this table. SELECT tags, COUNT(*) as Num FROM tagname GROUP BY tags ORDER BY Num DESC This will cost 23.88 seconds. return 358 kinds of tags tags | Num festival | 7201 art | 6988 gift | 6755 ... How to optimization this query, even in my.cnf ? I tried