Requirements are: For a device, the average of every hour of the day, the average of one months per day, the more general requirement is, from the start time to the end time, every time, to find an average.
The current solution is to process in the stored procedure, from the start time to the end time, cut into segments, to find out the average of each segment, merged together.
Problem: There are serious performance issues when there is a large amount of data. For example: The average of one months per day, the amount of data involved will be very large, the query is very time-consuming. There is no benchmark test, and the specific time consumption is uncertain.
Workaround: The idea now is to create a new mean table that periodically writes the average of a period of time to the table. Later from the average table inside the query.
MySQL Large data size averaging