Hello group,
Let’s say I want to list the items clicked the most the past 24 hours.
Sure,
I could do a query of a click table and count all the clicks the past 24
hours for each item and sort. After a while the click table will fill up
and
that count query will become slow.
I can think of 2 options:
-
Index the click count in a separate table, and increment the click
count
of each item. At each click, I guess I could do a click count of the
past 24
hours and store that click in a counter table. But it seems doing the
click
count at each click and saving that to the db might slow things down a
bit. -
I could count on the basis of a day and reset the counter table at
the
end of each day using a cron job. For example, at 12:00am reset the
counter
table and then start incrementing the counter from 0 at midnight. I’d
like
to do it without a cron job.
Is there a better way to index clicks over a 24 hour period?
Thanks,
Steve O.
http://www.smarkets.net