I have a mysql query that is joining a few tables and then uses order by field for sorting. It sometimes runs quite fast at other times it is slow. While it was slow i profiled the query to find that sorting was taking around 15 secs. But when it is fast the sorting takes only .5 seconds.
Please note it is the same query both the times on the same database. There are other queries running but nothing heavy.
It is bothering me, what might be causing this erratic behaviour