Answer the question
In order to leave comments, you need to log in
How to make a 24 Hour Highlights section?
How to organize a database table? Including indexes
I see such variant.
There is a table [post_id | time ], index by time (do you need it by post_id? Or is it better to omit it for faster insertion into the database?)
Where post_id is the id of the viewed post, and time is the viewing time.
Once every five minutes, upload totals from there with the number of views with a selection by time >= now () - 24h
What did I miss? Are there better options?
Answer the question
In order to leave comments, you need to log in
You can look at the "hot posts" algorithm on reddit .
You can store temporary data in Redis much more efficiently.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question