Hi, I am using this query to find group links and grouping number of votes on them and then sorting it If i don't put order by, everything is fine....but as soon as i put order by the query becomes slow and my page cannot open select sum(votes) as votes,url from sortingdisplay where mydate>=DATE_ADD(CURRENT_DATE,INTERVAL -7 DAY) and mydate<=CURRENT_DATE Group by url ORDER BY votes Is there any alternative to sort rather than order by...because order by is causing all this problem
1) You can try to use query without 'order by' and sort array with php function sort() 2) Is this part of query obligatory? 'mydate<=CURRENT_DATE' Code (markup): I mean that as I see you try to get link of last 7 days. But query is doing in 'now' in any case =) I think this condition is out of place. 3) Try to remake your one query in two different and simple.
Hi, PHP sort function makes it really slow and if i remove mydate <=current date, it doesn't help But if i remove Order by then the query works in .0005 secs which is great So i need a solution for order by
There isn't really a 'solution' for it as such, though it might pay to add an index on the votes column... that might speed things up a bit.