I'm planning to add a couple of usage statistics to my web application. Some common things like: registered users, amount of comments/posts, etc. over time (last 24 hours / last week / last month / last year) which I want to display graphically to all admins.
I know that I can retrieve all information from database queries, but I have a bad feeling going over "old data" over and over again.
Example: Yesterday, I requested the amount of users who registered for an account the last year. Admin XYZ requests the same statistic today. A simple select-all-users-reg-date-last-year query would be redundant and cause much database traffic, right?
What is the best approach of calculating statistical data like this?