Created Cached Results over Time (PHP/MySQL)

Hello all,

So, I have a bit of a tricky problem.

Essentially, I have a large number of results of something (taken as frequently as once per second).

I want to be able to view these records over time at set intervals (minutes, hours, weeks, etc).

So, obviously, if whenever I want to view this, if I wanted to view say 24 hours, at an interval of an hour, that’d take 86,400 records. O.o

What I want to do with those records is to essentially cache them the first time I create these results, so I can pull them out whenever I want.

My idea is to create them “on-demand”, so I’m not caching things that are never viewed. However, the tricky part with this is say I view a range from 3:00 - 6:00, then from 8:00 - 12:00, then I want to view 3:00 - 12:00. I have a gap in there, but I wouldn’t really be aware of that.

Anyone have any tips for how I could easily accomplish this without having to reprocess all of these results every time?

Thanks.