Topic: Data migration from the table in the table with mathematics
All good afternoon
There was such problem, is implemented now on PHP, but very much it would be desirable to transfer this process on MySQL
There are two tables
The first cpu_live
The second cpu
To the table cpu_live with periodicity in a second it is written the order of 100-200 records of which we on a site build the live schedule
id, machine_id, cpu, cpu1, cpu2, cpu3, cpu4, cpu5, cpu6, cpu7, cpu8, cpu9, cpu10, cpu11, cpu12, cpu13, cpu14, cpu15, cpu16, data_add
In the second table all is identical
It would be desirable to receive the following
To select it is admissible 10 oldest records on machine_id, to receive mean values of all columns and to save received by single line in cpu.
After that to delete these 10 oldest records
Then once again the same and so until while in cpu_live there is no data in the last 30 minutes
Like all is simple, but if is fair already all head broke
Just in case I will explain a problem entirely somebody can prompts more refined decision
Indications of processors are written to the table with periodicity in a second, I will repeat from them the live schedule for last 20-10 is under construction minutes.
By itself the schedule is drawn by request in
Faced that that when we try to make sampling in an hour, we have certain complexities as schedule detailing turns out to within a second, all right, hour still tolerantly, and here indications for a day set the server thinking...
While I see only two decisions or to do sampling with decimation, but in 30 minutes after arrival of the data to us them to store in this type there is already no sense or where that to store the data already in the thinned out type, and it actually a subject)
In advance thanks