From 6e586fa09c17a5bdc355394ec9570beb6a012e65 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Wed, 18 Sep 2019 23:24:12 +0300 Subject: [PATCH] lib/storage: skip duplicate call to intersectMetricIDsWithTagFilter on zero successful intersects --- lib/storage/index_db.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/storage/index_db.go b/lib/storage/index_db.go index 43d6116146..5b027ca964 100644 --- a/lib/storage/index_db.go +++ b/lib/storage/index_db.go @@ -1578,6 +1578,7 @@ func (is *indexSearch) updateMetricIDsForTagFilters(metricIDs map[uint64]struct{ // Find intersection of minTf with other tfs. var tfsPostponed []*tagFilter + successfulIntersects := 0 for i := range tfs.tfs { tf := &tfs.tfs[i] if tf == minTf { @@ -1594,6 +1595,10 @@ func (is *indexSearch) updateMetricIDsForTagFilters(metricIDs map[uint64]struct{ return err } minMetricIDs = mIDs + successfulIntersects++ + } + if len(tfsPostponed) > 0 && successfulIntersects == 0 { + return is.updateMetricIDsByMetricNameMatch(metricIDs, minMetricIDs, tfsPostponed, tfs.accountID, tfs.projectID) } for i, tf := range tfsPostponed { mIDs, err := is.intersectMetricIDsWithTagFilter(tf, minMetricIDs)