From 1d4e456652c5457f07f25165e9a9dfaf27bcd32f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20S=CC=8Ctibrany=CC=81?= Date: Mon, 20 Apr 2020 16:47:28 +0200 Subject: [PATCH 1/2] Remove optimizations for label=~".*" and label!~".*". MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit They are not correct. Signed-off-by: Peter Štibraný --- pkg/store/bucket.go | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/pkg/store/bucket.go b/pkg/store/bucket.go index c7d81098a7..ba5f0548ef 100644 --- a/pkg/store/bucket.go +++ b/pkg/store/bucket.go @@ -1485,23 +1485,8 @@ func checkNilPosting(l labels.Label, p index.Postings) index.Postings { return p } -var ( - allPostingsGroup = newPostingGroup(true, nil, nil) - emptyPostingsGroup = newPostingGroup(false, nil, nil) -) - // NOTE: Derived from tsdb.postingsForMatcher. index.Merge is equivalent to map duplication. func toPostingGroup(lvalsFn func(name string) ([]string, error), m *labels.Matcher) (*postingGroup, error) { - // This matches any label value, and also series that don't have this label at all. - if m.Type == labels.MatchRegexp && (m.Value == ".*" || m.Value == "^.*$") { - return allPostingsGroup, nil - } - - // NOT matching any value = match nothing. We can shortcut this easily. - if m.Type == labels.MatchNotRegexp && (m.Value == ".*" || m.Value == "^.*$") { - return emptyPostingsGroup, nil - } - if m.Type == labels.MatchRegexp && len(findSetMatches(m.Value)) > 0 { vals := findSetMatches(m.Value) toAdd := make([]labels.Label, 0, len(vals)) From a4889a11d611de60b38fbdf042ccc224abb1efc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20S=CC=8Ctibrany=CC=81?= Date: Mon, 20 Apr 2020 16:51:18 +0200 Subject: [PATCH 2/2] CHANGELOG.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Peter Štibraný --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5edf441d56..d64e641089 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ We use *breaking* word for marking changes that are not backward compatible (rel ### Changed - [#2450](https://github.com/thanos-io/thanos/pull/2450) Store: regex-set optimization for `label=~"a|b|c"` matchers. +- [#2475](https://github.com/thanos-io/thanos/pull/2475) Store: remove incorrect optimizations for queries with `=~".*"` and `!=~".*"` matchers. ## [v0.12.0](https://github.com/thanos-io/thanos/releases/tag/v0.12.0) - 2020.04.15