1
0
mirror of https://github.com/beestat/app.git synced 2025-05-24 02:14:03 -04:00

Optimized metric fetching.

This commit is contained in:
Jon Ziebell 2021-02-22 19:47:46 -05:00
parent bb93805e20
commit bdcb59a2c4

View File

@ -491,17 +491,22 @@ class thermostat extends cora\crud {
}
}
$memory_limit = 16; // mb
$memory_per_thermostat = 0.0054; // mb
$limit_start = 0;
$limit_count = 250;
$limit_count = round($memory_limit / $memory_per_thermostat);
/**
* Selecting lots of rows can eventually run PHP out of memory, so chunk
* this up into several queries to avoid that.
*/
do {
var_dump('before = ' . memory_get_usage());
$result = $this->database->query('
select
*
thermostat_id,
profile
from
thermostat
where ' .