Jump to content

Page Views


The Little Guy

Recommended Posts

I would go with b.  It is the easiest and fastest way to count the views instead of going through all the records, especially if your video collection expands.  Every time someone views the video, just increment by 1 and you're done...

Link to comment
Share on other sites

a. The row would contain information about the user, such as: ip, date viewed, user id (if they are logged in) for sure. Maybe some other info too. If I went with option b. I would then use option a. as well, because I don't want to increment the count if the user refreshes the page, only if they come back 24 hours later.

Link to comment
Share on other sites

a good solution would be to have a log table for all

video views. therefore you are free to analyze this

data later on like views per hour etc.

 

on a next step you build a cronjob which counts

all video views and writes the sum into one table

field (update col countviews in video table).

Link to comment
Share on other sites

a good solution would be to have a log table for all

video views. therefore you are free to analyze this

data later on like views per hour etc.

 

This is what I was thinking...

 

I wanted to do option a, because I currently have a table that has almost 9K rows in it, and it queries a count in less than one second.  The problem is, will this take WAY too long when there is say 1M - 5M rows?

 

on a next step you build a cronjob which counts

all video views and writes the sum into one table

field (update col countviews in video table).

 

I would like to minimize the number of queries to do this, and the only way I know of would be to make a loop, that does a query every single pass, and if I have 20,000 videos, this would do around 40,000 queries, not cool.

Link to comment
Share on other sites

The Little Guy:

Try to use both options: separate table "video_log" for occasional statistics with ip, date viewed, user id ... and grand total in table "video" for displaying on each request for page.

 

if I have 20,000 videos, this would do around 40,000 queries

 

SELECT COUNT(video_id) FROM video_log GROUP BY (video_id) - this is 1 query for select.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.