Does the order of the columns in the group by affect performance?
The short answer: Yes.
It's not always as obvious as the order of the columns in a sorting key, but as GROUP BY
is a heavy operation, you should always experiment with the GROUP BY
to find the optimal order. Changing the order of the columns in your GROUP BY
is pretty easy, and can be surprisingly effective!