I'm working on an app, and I want to be able to pull stats on how many times certain pages are viewed.
As of now, I have a method that works, but I know it's not efficient.
I keep a log of hits in a table. hitID, pageID, date, ip, user, etc. etc.
In order to compile 'how many' hits, I was just doing a basic 'select hitID where pageID=pageID' and using the returned 'record count'.
However, I'm doing an ajax ticker that can be enabled to see hits scroll through in real time.
What I'm thinking about doing is creating another table called 'hit count' and just doing a +1 to the hitID's hit number everytime a new hit is logged. I can always recompile the number, and I'm thinking having that number available immediately via db rather than having to scan a bunch of records counting will be incredibly faster.
And since I'd have that number availabe, I could do a simple ajax call to a method that returns just the hit count via json. With this, I can check that number before making a larger request to get updated info.
make sense? Thoughts?
As of now, I have a method that works, but I know it's not efficient.
I keep a log of hits in a table. hitID, pageID, date, ip, user, etc. etc.
In order to compile 'how many' hits, I was just doing a basic 'select hitID where pageID=pageID' and using the returned 'record count'.
However, I'm doing an ajax ticker that can be enabled to see hits scroll through in real time.
What I'm thinking about doing is creating another table called 'hit count' and just doing a +1 to the hitID's hit number everytime a new hit is logged. I can always recompile the number, and I'm thinking having that number available immediately via db rather than having to scan a bunch of records counting will be incredibly faster.
And since I'd have that number availabe, I could do a simple ajax call to a method that returns just the hit count via json. With this, I can check that number before making a larger request to get updated info.
make sense? Thoughts?