After reading How MySQL Uses Indexes i was left with a doubt:
is there benefit in turning column A and column B into indexes, in case they will be summed in most of my queries?
My question is mostly because the above link lists MIN and MAX functions, as well as COUNT() and they belong to the same group as SUM (aggregate functions):
http://dev.mysql.com/doc/refman/5.0/en/group-by-functions.html#function_sum
You use indexes to help find stuff. So you need that in columns that you use in the where clauses and in joins and in order/group by. Once you have the rows you want, that is when you start counting and summing and then indexes won’t help.
So if the columns are used in the select: no
In where or join: yes
In order/group by: possibly.
PS: For select min()/max() on all rows on a table, indexes help cause you don’t have to scan the table but find it directly. The same does not apply to sum.