I don't see a necessity to change the whole db technology or infrastructure just because you need a little bit of optimizing here. Start with something simple like writing a stored procedure (or maybe a client program in your favorite programming language) and collect the results in a new table. If you do it right, the memory needed will be proportional to the number of different pairs (account_id,name
), not more. I guess that number is much smaller than the number of orders.
On a larger scale, inform yourself about data warehouseing, and how to model things like a "star schema" for the kind of queries you mentioned. You will find plenty of books, tutorials and information on the web for this. "ETL" will indeed be the right term to search for, since it is the kind of process you need to fill your "data warehouse".