From fcaa0c5202bfaa3a37f2a1bb483cf33a167ed579 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Mon, 21 Feb 2022 18:20:36 +0200 Subject: [PATCH] lib/storage: optimize `/api/v1/status/tsdb` call by skipping all the artificially created tag entries at once This is a follow-up for b71be42d9065417ed2b49807e93f80b970ca8cbe --- lib/storage/index_db.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/storage/index_db.go b/lib/storage/index_db.go index b0261442b..ec698ab57 100644 --- a/lib/storage/index_db.go +++ b/lib/storage/index_db.go @@ -1423,6 +1423,14 @@ func (is *indexSearch) getTSDBStatusWithFiltersForDate(tfss []*TagFilters, date } if isArtificialTagKey(tmp) { // Skip artificially created tag keys. + kb.B = append(kb.B[:0], prefix...) + if len(tmp) > 0 && tmp[0] == compositeTagKeyPrefix { + kb.B = append(kb.B, compositeTagKeyPrefix) + } else { + kb.B = marshalTagValue(kb.B, tmp) + } + kb.B[len(kb.B)-1]++ + ts.Seek(kb.B) continue } if len(tmp) == 0 {