Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
damnever committed Aug 12, 2022
1 parent 3618b14 commit fb5014a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pkg/store/bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -1809,6 +1809,10 @@ func (r *bucketIndexReader) ExpandedPostings(ctx context.Context, ms []*labels.M
keys = append(keys, allPostingsLabel)
}

// Sorting will improve the performance dramatically if the dataset is relatively large
// since entries in the postings offset table was sorted by label name and value,
// the sequential reading is much faster.
sort.Sort(labels.Labels(keys))
fetchedPostings, err := r.fetchPostings(ctx, keys)
if err != nil {
return nil, errors.Wrap(err, "get postings")
Expand Down Expand Up @@ -1890,7 +1894,6 @@ func checkNilPosting(l labels.Label, p index.Postings) index.Postings {
func toPostingGroup(lvalsFn func(name string) ([]string, error), m *labels.Matcher) (*postingGroup, error) {
if m.Type == labels.MatchRegexp {
if vals := findSetMatches(m.Value); len(vals) > 0 {
sort.Strings(vals)
toAdd := make([]labels.Label, 0, len(vals))
for _, val := range vals {
toAdd = append(toAdd, labels.Label{Name: m.Name, Value: val})
Expand Down

0 comments on commit fb5014a

Please sign in to comment.