lib/storage: add a comment to indexSearch.containsTimeRange() on why it allows false positives

Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/2239
This commit is contained in:
Aliaksandr Valialkin 2022-02-24 12:47:24 +02:00
parent 02a922b53f
commit d1881fa582
No known key found for this signature in database
GPG key ID: A72BEC6CD3D0DED1

View file

@ -1893,7 +1893,12 @@ func (is *indexSearch) containsTimeRange(tr TimeRange) (bool, error) {
ts := &is.ts
kb := &is.kb
// Verify whether the maximum date in `ts` covers tr.MinTimestamp.
// Verify whether the tr.MinTimestamp is included into `ts` or is smaller than the minimum date stored in `ts`.
// Do not check whether tr.MaxTimestamp is included into `ts` or is bigger than the max date stored in `ts` for performance reasons.
// This means that containsTimeRange() can return true if `tr` is located below the min date stored in `ts`.
// This is OK, since this case isn't encountered too much in practice.
// The main practical case allows skipping searching in prev indexdb (`ts`) when `tr`
// is located above the max date stored there.
minDate := uint64(tr.MinTimestamp) / msecPerDay
kb.B = is.marshalCommonPrefix(kb.B[:0], nsPrefixDateToMetricID)
prefix := kb.B