Skip to content

Commit

Permalink
Store: improve index header reading performance by sorting labels
Browse files Browse the repository at this point in the history
  • Loading branch information
damnever committed Aug 11, 2022
1 parent 292dbb7 commit 0aa5dda
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/store/bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -1855,6 +1855,10 @@ func (r *bucketIndexReader) ExpandedPostings(ctx context.Context, ms []*labels.M
keys = append(keys, allPostingsLabel)
}

// Sort label name and value will improve the performance dramatically
// if the dataset is relatively large, since entries in postings offset table
// are sorted by label name and value, sequential reading is always faster.
sort.Sort(labels.Labels(keys))
fetchedPostings, err := r.fetchPostings(ctx, keys)
if err != nil {
return nil, errors.Wrap(err, "get postings")
Expand Down

0 comments on commit 0aa5dda

Please sign in to comment.