D
D
DTX2016-04-12 17:32:04
PHP
DTX, 2016-04-12 17:32:04

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

1 answer(s)
R
Roman Kitaev, 2016-04-12
@DirecTwiX

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 question

Ask a Question

731 491 924 answers to any question