lib/storage: optimization: do not scan block for rows outside retention if it is covered by the retention

This commit is contained in:
Aliaksandr Valialkin 2022-12-03 22:14:12 -08:00
parent 152ac564ab
commit 5ca58cc4fb
No known key found for this signature in database
GPG key ID: A72BEC6CD3D0DED1

View file

@ -178,6 +178,10 @@ func mergeBlocks(ob, ib1, ib2 *Block, retentionDeadline int64, rowsDeleted *uint
}
func skipSamplesOutsideRetention(b *Block, retentionDeadline int64, rowsDeleted *uint64) {
if b.bh.MinTimestamp >= retentionDeadline {
// Fast path - the block contains only samples with timestamps bigger than retentionDeadline.
return
}
timestamps := b.timestamps
nextIdx := b.nextIdx
nextIdxOrig := nextIdx