On any website, such as on StackOverflow, each question has a view count, and user reading a question but has previous read it won\'t count twice.
I have some ideas abou
On my website I deal with counting guest views and the 'mass of data' this produces by dividing down the number of views using a random number.
Say I have a random number generator with a good distribution between 0 and 1, and I'm getting 100,000 views a day on a particular page. If I call the 'logView()' function every view, but in it generate an new random number and only really log the view to the DB when the random number is < 0.001, then for the 100,000 views I will only hit the DB approximately 100,000*0.001 = 1000 times.
If I want to return a view count, then I just divide my DB number by the same value, eg. 1000/0.001 = 100,000. This is approximatly accurate to the nearest 1000 views.
Obviously you can choose a random number range dependent on the load of your site, and even change this if your load changes dramatically (you just need to modify your stored values accordingly).
Also, a page with only 1000 views may not even get a 1 in the view count, but if you have a page with 100,000 views, then the one with 1000 is pretty insignificant.
You have a couple of options as I see it.
Cookies
You can store a cookie in the users browser for each page you are logging views on. Check for this cookies existence and don't log a view if the cookie already exists.
Downside to this is that it won't work if cookies are disabled or someone is trying to game the system.
On the plus side you don't have to worry about the storage of potentially millions/billions of rows of table data.
Database
You hold a record for each view. Relating that record to a user in some way e.g. MemberID, IP Address; something that should be unique to the user. IP is not ideal but good enough if you are not requiring users to login.
So you would have for example a table with the following columns,
The date will be useful for a couple of reasons,
If your application gets popular in this situation then you will need to deal with the storage implications. I run a popular Facebook app which results in over 100,000 view rows being added each day. Realistically though if your app gets so popular that it becomes a problem then you'll have much bigger issues to deal with.
Short answer: It depends!
I've previously used cookies combined with an in-memory database to store the individuals view's (for obvious reasons I stored the actual view count in a database table persisted to disk). I could do this because the statistics didn't mean anything.
It looks like stackoverflow does not count guest (unlogged) users viewing a topic. The issue with counting anonymous user views is that your counter can be gamed. Someone can always delete the cookie and view again. Logging the views is the safest solution for accuracy, but of course you have two major problems: size of the table and lack of guest/anonymous users. It surprises me that stackoverflow is not logging guest (unlogged) users. I would think that the majority of views would come from these users doing google searches.
When most of the visitors to your site are registered it's relatively easy to make sure none of them are counted twice.
I'm not sure if SO counts views by guests. I suppose I could check but it's late.
I'll try to give an answer from the functional point of view.
count views per user - for registered users. for anonymous users - per session.
increment view count on the first view and on any view after a significant update by someone other that the person viewing the item.
view of poster at the time of creation should not count
you can imagine doing it simpler too, but I've tried to think of an ideal solution.