I have a table which is updated every 10 seconds with data. I need to get an average for 10 minutes, for 24 hours for a particular date.
I tried doing this and increment the time by 10 mins through php.
select AVG(active_energy), date_time from energy_readings where date_time between "2016-11-02 00:00:00" and "2016-11-02 00:00:00"+ INTERVAL 10 MINUTE;
and then
select AVG(active_energy), date_time from energy_readings where date_time between "2016-11-02 00:10:00" and "2016-11-02 00:10:00"+ INTERVAL 10 MINUTE;
for 24 hours.
It works, but it takes too much load on my database server.
Is there a single mysql query that I can use which will give me 10 min averages for 24 hours for a particular day?