We have a MySQL database where we have added time series values.
-------------------------------------
|Col A | Col B | Timestamp |
-------------------------------------
|1.23 | 4.48 |2013-09-03 10:45:27 |
-------------------------------------
|1.23 | 4.48 |2013-09-03 10:46:27 |
-------------------------------------
|1.23 | 4.48 |2013-09-03 10:47:27 |
-------------------------------------
The data is unevenly spaced w.r.t time, some points are separated by a minute & some by a few seconds.
Is there an efficient way I could query this database to pull data for every n
th minute/second/hour? Ideally I would want the (linear) interpolated value at the n
th minute, but the closest point to the n
th minute or the last point just before or at the n
th point would do too.
The use case being I want to plot this into a graph, but do not want too many points than necessary. So for plotting for a year, I would prefer querying only a couple of points a day. While plotting for a day, I would want to plot a point every minute or so.
I can do all this in PHP, but is there a way to do it directly in the database? If not, I am contemplating the usage of a time series database, but the budget constraints restricts me to only the free ones. Is there any free time series database that gives out of the box sampling and preferably interpolation?