mysql - How to optimize data aggregation in day of week, time of day for a period of one month back -
    here situation:   i have saas application simple rss feed reader. think people know - users subscribing rss feeds , reading items them. nothing new. 1 feed can have many subscribers.   i've implemented statistics users, don't think i've chosen right approach, because things getting slower hour number of users , feeds grows.   here's i'm doing now:    at every hour total number of articles each feed:   select count(*) articles feed_id=?  get previous value calculate delta (this getting little slow):   select value feeds_stats feed_id=? , name='total_articles' order date desc limit 1  insert new value , delta:   insert feeds_stats (date,feed_id,name,value,delta) values ('".date("y-m-d h:i:s",$global_timestamp)."','".$feed_id','total_articles','".$value."','".($value-$old_value)."')  for every user feeds , each feed number of articles has read:   select count(*) users_artic...