Limit the returned db.Querier to the requested time range (#351)

Limit the returned `db.Querier` to the requested time range. Preallocate the `baseChunkSeries.lset` and `baseChunkSeries.chks` slices to the previous series' slice sizes to avoid unnecessary grow slice reallocations.
This commit is contained in:
Alin Sinpalean 2018-11-09 14:54:56 +01:00 committed by Krasi Georgiev
parent e4843938ba
commit 171fc4ab5d
2 changed files with 7 additions and 3 deletions

6
db.go
View File

@ -793,7 +793,11 @@ func (db *DB) Querier(mint, maxt int64) (Querier, error) {
}
}
if maxt >= db.head.MinTime() {
blocks = append(blocks, db.head)
blocks = append(blocks, &rangeHead{
head: db.head,
mint: mint,
maxt: maxt,
})
}
sq := &querier{

View File

@ -499,8 +499,8 @@ func (s *baseChunkSeries) Err() error { return s.err }
func (s *baseChunkSeries) Next() bool {
var (
lset labels.Labels
chkMetas []chunks.Meta
lset = make(labels.Labels, len(s.lset))
chkMetas = make([]chunks.Meta, len(s.chks))
err error
)