Hi I need some optimization help.
I currently have this query "SELECT COUNT(*) as count,sum(p.amt) as total,p.batch,m.username,m.id,p.method,DATE_FORMAT(p.occur, '%M %d, %Y') as dateBought FROM pay p LEFT JOIN members m ON m.id=p.mid WHERE p.method!='none' AND p.method!='' GROUP BY p.batch ORDER BY p.occur DESC" Now I have an index on batch,method but that does not help because its using filesort when ordering because of "occur". Also I wanted to know if there is a way to optimize SUM, and does DATE_FORMAT slow down queries, would it be faster to run my own php date function once i get there queries. Thanks, Andrew