@cryptotaxi247 / netdata-1 / commits / eabc8d4e0

QUERIES: use tiers only when they have useful data (#16263)

use tiers only when they have useful data

Costa Tsaousis committed Oct 23, 2023 at 22:55 UTC eabc8d4e0f250f647115e5203897f757ef9d1878
1 file changed +4 -2
web/api/queries/query.c
+4 -2
@@ -1391,9 +1391,10 @@ static bool query_plan(QUERY_ENGINE_OPS *ops, time_t after_wanted, time_t before
1391
1392 // find the first time of this tier
1393 time_t tier_first_time_s = qm->tiers[tr].db_first_time_s;
1394 + time_t tier_last_time_s = qm->tiers[tr].db_last_time_s;
1395
1396 // can it help?
1396 - if (tier_first_time_s < selected_tier_first_time_s) {
1397 + if (tier_first_time_s < selected_tier_first_time_s && tier_first_time_s <= before_wanted && tier_last_time_s >= after_wanted) {
1398 // it can help us add detail at the beginning of the query
1399 QUERY_PLAN_ENTRY t = {
1400 .tier = tr,
@@ -1423,12 +1424,13 @@ static bool query_plan(QUERY_ENGINE_OPS *ops, time_t after_wanted, time_t before
1424 continue;
1425
1426 // find the last time of this tier
1427 + time_t tier_first_time_s = qm->tiers[tr].db_first_time_s;
1428 time_t tier_last_time_s = qm->tiers[tr].db_last_time_s;
1429
1430 //buffer_sprintf(wb, ": EVAL BEFORE tier %d, %ld", tier, last_time_s);
1431
1432 // can it help?
1431 - if (tier_last_time_s > selected_tier_last_time_s) {
1433 + if (tier_last_time_s > selected_tier_last_time_s && tier_first_time_s <= before_wanted && tier_last_time_s >= after_wanted) {
1434 // it can help us add detail at the end of the query
1435 QUERY_PLAN_ENTRY t = {
1436 .tier = tr,