"order by" taking too much time in mysql
Solution 1:
If you don't have an index on the field that you're ordering by, add one:
"In some cases, MySQL can use an index to satisfy an ORDER BY clause without doing any extra sorting."
Edit: (From the section on ORDER BY optimization in the MySQL documentation.)
Solution 2:
Adding appropriate indexes for the fields you're ordering by should do the trick.
Solution 3:
You may be able to increase the speed of returning sorted results by adding an index on the column(s) that you want your results ordered by.
Solution 4:
ALTER TABLE `tablename` ADD INDEX `indexname` (`columnname`);
Generally, indexname is the same as columnname.