I am working on a video site. It's pretty heavy so far as traffic is concerned. I am trying to rank videos by the number of times videos are viewed. I.e. video A gets 5.2K views and B gets 5k views, so A ranks above B. But I want to calculate the views each video gets in a week (or a month, if needed) and then rank them by view counts.
I first created a table that contains views only. i.e. every time, a video is viewed a row is inserted into the table along with timestamp and video id. That was a horrible decision. Since the traffic was heavy, the table became huge, affecting performance. Is there is a better way to do this?