I had a mysql query in a php script that was taking too long to run, over 6 seconds usually.
I tried running that query in phpmyadmin and I noticed that it was running way faster. I also noticed that phpmyadmin was automatically appending "LIMIT 0,30" at the end of my query. Since the rows returned from this query are never more than 60, i decided to add a "LIMIT 0,60" at the end of my query in the php script. To my surprise this made the query (and the script) run 30 times faster!!
Can this be right or should I be missing something? I find it hard to believe that such kind of change can have such a dramatic effect. Actually I am surprised it can have any effect at all, since the rows returned were never more than 60 anyway, so the LIMIT clause seems totally redundant in this case.
I am running MySQL 4.1.22
The query includes "SELECT DISTINCT" 5 "LEFT JOIN", "GROUP BY" and "ORDER BY" ... if this matters at all.