I'm creating a simple analytics script to use on my website(s). I started of very simply by just creating a new record for every session, and updating the sessions (i.e. incrementing the number of pageloads for that session) when a new page is loaded. I also save the browser/version and platform the visitor is using.
This works fine as it is, though it is not really efficient in any way. I've tested the script with a few (say 20 or so) records in the table, but I don't think everything will run as smoothly as it does now when the website is being visited more frequently.
Now I have been thinking how to optimize this. The problem I'm facing is: If I were to, for example, only save the number of pageloads and the number of sessions (I could use the 2 numbers to calculate a average pageloads per session), I will be unable to make a graph of pageloads over the last X days.
So my question is: How do I optimize this system in a way that I can still use the data in multiple ways?
Thanks in advance.