I have a total of 500,000 records inside a table and I need to sum some fields up from this records and group it by customer.
I am using MySQL as my db and PHP as my web language. I am wondering whether a MySQL SUM() AND GROUP BY statement is faster or a PHP LOOP of all the 500K of records to sum it up is faster?
Let's assume that my table have all the indexes that the SQL statment needs. It would be great to share this with everyone !
Thanks in advance.