Hi,
As the title suggests this is a design question.
Imagine this simple example. I have a File entity and every time someone would view the file that would be considered to be a visit.
I have two options to count the visits
1. the strainght forward way, keeping a file_visit table that will create a record everytime when the file is visited. That implies that in order to get a list of files I'd need to run a count as a formula thing. Visits are not going to be ever displayed or used of a different purpose but counting.
Avantages:
- clean and simple solution
- works well in clustered env.
Disavantanges:
- can create problems if items are very popular they would have a zillion of entries in the visit table hence a degradation of performance.
2. Maintaining a visits field in the File table and incrementing it when the item would be display/downloaded. THis sounds easier than is done.
Advantages
- increased performance, no additional db calls
Disadvantages
- can create issues in clustered enviroment with respect to the synchronizing the updates of the field while the file is viewed in the same time.
A common question, how is this working with a cached entity. I'm using a second level cache and I'd refresh this number since all other people are using it.
What are your thoughts? How is the best way of doing this fairly simple solution.
Regards,
Q
http://www.goodstockimages.com