Should I do computing each time I do analytics on my data from database?

I have an app. Where so much data is stored in my database. as an example.

I want to find out how many earning did store made in a year when store owner opens his app?

then should I need to grab all the entire year's data(I would be almost 50000-100000 number of lines) and process on the client-side and find out the analytics? that how much did the store earned in a year.

or

I need to use something diffrent like when user place a new order then server will calulate the the price and save to database and again if another user places an order than it agian caluclates and sums up with the saved value in the database field called analitics with storename?

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum