I have a very simple query and it executes in 0.0043 seconds WITHOUT the "ORDER BY" clause.
When I introduce the ORDER BY clause (as seen below) the query suddenly becomes over 5 seconds.
I can't index the order by column because it is a dynamic column in a temporary, temporary table that is created on-the-fly by MySQL at the time of execution.
So why is it so slow? And what can I do to speed it up.
With ORDER BY clause: 5.0443 seconds
Without ORDER BY clause: 0.0043 seconds
MIN(d.price) AS price,
COUNT(d.iddeals) AS deals,
items AS i
deals AS d
ON d.iditems = i.iditems