From bdcb59a2c4df04b96e1a9cb98146abf060a97349 Mon Sep 17 00:00:00 2001 From: Jon Ziebell Date: Mon, 22 Feb 2021 19:47:46 -0500 Subject: [PATCH] Optimized metric fetching. --- api/thermostat.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/api/thermostat.php b/api/thermostat.php index 0cddbfe..040c793 100644 --- a/api/thermostat.php +++ b/api/thermostat.php @@ -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 ' .