summaryrefslogtreecommitdiffstats
path: root/web/api/queries/query.c
diff options
context:
space:
mode:
Diffstat (limited to 'web/api/queries/query.c')
-rw-r--r--web/api/queries/query.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/web/api/queries/query.c b/web/api/queries/query.c
index 8a4e94c96..b7e89ee97 100644
--- a/web/api/queries/query.c
+++ b/web/api/queries/query.c
@@ -1391,9 +1391,10 @@ static bool query_plan(QUERY_ENGINE_OPS *ops, time_t after_wanted, time_t before
// find the first time of this tier
time_t tier_first_time_s = qm->tiers[tr].db_first_time_s;
+ time_t tier_last_time_s = qm->tiers[tr].db_last_time_s;
// can it help?
- if (tier_first_time_s < selected_tier_first_time_s) {
+ if (tier_first_time_s < selected_tier_first_time_s && tier_first_time_s <= before_wanted && tier_last_time_s >= after_wanted) {
// it can help us add detail at the beginning of the query
QUERY_PLAN_ENTRY t = {
.tier = tr,
@@ -1423,12 +1424,13 @@ static bool query_plan(QUERY_ENGINE_OPS *ops, time_t after_wanted, time_t before
continue;
// find the last time of this tier
+ time_t tier_first_time_s = qm->tiers[tr].db_first_time_s;
time_t tier_last_time_s = qm->tiers[tr].db_last_time_s;
//buffer_sprintf(wb, ": EVAL BEFORE tier %d, %ld", tier, last_time_s);
// can it help?
- if (tier_last_time_s > selected_tier_last_time_s) {
+ if (tier_last_time_s > selected_tier_last_time_s && tier_first_time_s <= before_wanted && tier_last_time_s >= after_wanted) {
// it can help us add detail at the end of the query
QUERY_PLAN_ENTRY t = {
.tier = tr,