Jump to content

Page Views


The Little Guy

Recommended Posts

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
https://forums.phpfreaks.com/topic/130771-page-views/#findComment-678752
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
https://forums.phpfreaks.com/topic/130771-page-views/#findComment-679169
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
https://forums.phpfreaks.com/topic/130771-page-views/#findComment-679415
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
https://forums.phpfreaks.com/topic/130771-page-views/#findComment-679545
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.