From c05885fb5fe6ca5e2324dd5834807a1927d93ab3 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Wed, 18 Sep 2019 19:07:46 +0300 Subject: [PATCH] lib/storage: mark tag filter returning errFallbackToMetricNameMatch as useless This will save CPU on subsequent calls for this filter --- 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 100aaa89d1..43d6116146 100644 --- a/lib/storage/index_db.go +++ b/lib/storage/index_db.go @@ -1406,6 +1406,11 @@ func (is *indexSearch) getTagFilterWithMinMetricIDsCount(tfs *TagFilters, maxMet if err != nil { if err == errFallbackToMetricNameMatch { // Skip tag filters requiring to scan for too many metrics. + kb.B = append(kb.B[:0], uselessSingleTagFilterKeyPrefix) + kb.B = encoding.MarshalUint64(kb.B, uint64(maxMetrics)) + kb.B = tf.Marshal(kb.B, tfs.accountID, tfs.projectID) + is.db.uselessTagFiltersCache.Set(kb.B, uselessTagFilterCacheValue) + uselessTagFilters++ continue } return nil, nil, fmt.Errorf("cannot find MetricIDs for tagFilter %s: %s", tf, err)