Answer the question
In order to leave comments, you need to log in
Caching the result vs constant recalculation of the same?
The server sends some data to the clients. For example, a report on store statistics per day. It contains rows with totals of purchases including all taxes etc. and the last row is the sum of all categories (it is required to sum many things and many rows). The total tax for all goods, the total amount of purchases, etc. That is, with each request to the server, you need to give this data to everyone who asks. What is the best way to organize this - each time recalculate the amount for a new one for each request, or store the "amount" field in the database and increase it when adding a new purchase?
PS If you constantly consider the same thing, theoretically, the process will work in vain. Why endlessly recalculate the same thing when you can just store the result and update it as new rows arrive in the table?
Answer the question
In order to leave comments, you need to log in
How long does this summation take?
How many times a day do you need to give this statistics?
How long does it take to deliver the rest of the content?
Early optimization will not lead to good.
You can spend a lot of time and nerves validating the cache and not see any difference in performance.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question