Is creating an index for a column that is being summed is faster than no index?
I found indexing a column in the where(productid here) helps when using this query:
SELECT productid, sum(quantity) FROM receipts WHERE productid = 1 GROUP BY productid
One of my queries went from 45 seconds to almost instant once I added the index.