In my previous blog post I talk about GROUP BY
and ORDER BY optimizations. A member asked a great question that
I'd like to share with everyone.
But what if the query was:
SELECT c1, c2, c3, SUM(c4) FROM T WHERE c1 = ? GROUP BY c2 ORDER
BY c3 DESC LIMIT 10;
[Read more]
That query would produce a temp table and a filesort.
explain SELECT c1, c2, c3, SUM(c4) FROM column_test WHERE c1 = 1 GROUP BY c2 ORDER BY c3 DESC LIMIT 10\G
*************************** 1. row ***************************
id: 1
select_type: SIMPLE
table: column_test
type: ref
possible_keys: c1
key: c1
key_len: 5
ref: const
rows: 1
Extra: Using where; Using index; Using temporary; Using …