Hello,
I have table (MyISAM) with columns views_total
, views_24h
, views_7d
, views_30d
. views_24h
= view for last 24 hours, views_7d
= last 7 days etc. All this columns are INT and INDEX because I'm doing sorting by them.
Every hour (for 24h), or every day (for 7d, 30d) I'm updating this columns using UPDATE ... JOIN (... UNION ALL ...) USING ... SET ...
UPDATE itself takes about 2.5 sec. (100-120K rows), but before updating this columns I should set them to null. So, I'm making UPDATE table SET views_24h = 0
and this query takes about 4 seconds.
Is there any way to speed this UPDATE? Maybe, I should choose another algorithm or another data-model for this purposes? Maybe, I should separate this fields into another table and just do DELETE (but I will cause load during JOIN when displaying)?
I have pretty good NoSQL solution for this (Redis's ZSET datatype), but I want realize first how to do it quickly in MySQL...
Thank you.