app/vmselect/promql: intern output series names during normal aggregation

This commit is contained in:
Aliaksandr Valialkin 2023-01-09 22:15:24 -08:00
parent 21ee9a1fab
commit 562d6bca08
No known key found for this signature in database
GPG key ID: A72BEC6CD3D0DED1

View file

@ -7,6 +7,7 @@ import (
"strconv"
"strings"
"github.com/VictoriaMetrics/VictoriaMetrics/lib/bytesutil"
"github.com/VictoriaMetrics/VictoriaMetrics/lib/logger"
"github.com/VictoriaMetrics/VictoriaMetrics/lib/storage"
"github.com/VictoriaMetrics/metrics"
@ -118,13 +119,14 @@ func aggrFuncExt(afe func(tss []*timeseries, modifier *metricsql.ModifierExpr) [
if keepOriginal {
ts = argOrig[i]
}
tss := m[string(bb.B)]
k := bytesutil.InternBytes(bb.B)
tss := m[k]
if tss == nil && maxSeries > 0 && len(m) >= maxSeries {
// We already reached time series limit after grouping. Skip other time series.
continue
}
tss = append(tss, ts)
m[string(bb.B)] = tss
m[k] = tss
}
bbPool.Put(bb)