app/vmselect/netstorage: reduce the number of disk seeks when the query processes big number of time series

This commit is contained in:
Aliaksandr Valialkin 2019-09-28 20:30:58 +03:00
parent 56dff57f77
commit e92e39eddf

View file

@ -786,6 +786,14 @@ func ProcessSearchQuery(at *auth.Token, sq *storage.SearchQuery, fetchData bool,
pts.addrs = addrs
}
// Sort rss.packedTimeseries by the first addr offset in order
// to reduce the number of disk seeks during unpacking in RunParallel.
// In this case tmpBlocksFile must be read almost sequentially.
sort.Slice(rss.packedTimeseries, func(i, j int) bool {
pts := rss.packedTimeseries
return pts[i].addrs[0].offset < pts[j].addrs[0].offset
})
return &rss, isPartialResult, nil
}