I have these two queries:
SELECT SQL_NO_CACHE DISTINCT(type) FROM actions LIMIT 0, 30;
and
SELECT SQL_NO_CACHE type FROM actions GROUP BY type LIMIT 0, 30;
If I don't use the LIMIT clause, the execution times are equal. On the other hand, in my case, the first query takes almost 0.8 seconds, while the second takes 0.12 seconds.
Using EXPLAIN, it seems that the only difference is that first query uses a temporary table, while the second does not.
At this point I'm quite astonished by the different behavior of the two queries... can you provide some enlightenment on the problem?
I am currently using MYSQL 5.5.37-35.1 Percona Server (GPL), Release 35.1, Revision 666