mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-15 16:30:55 +01:00
lib/storage: move composite filters to the top during sorting
This commit is contained in:
parent
2005d8212a
commit
b4c7d5992b
@ -257,9 +257,19 @@ type tagFilter struct {
|
||||
graphiteReverseSuffix []byte
|
||||
}
|
||||
|
||||
func (tf *tagFilter) isComposite() bool {
|
||||
k := tf.key
|
||||
return len(k) > 0 && k[0] == compositeTagKeyPrefix
|
||||
}
|
||||
|
||||
func (tf *tagFilter) Less(other *tagFilter) bool {
|
||||
// Move regexp and negative filters to the end, since they require scanning
|
||||
// all the entries for the given label.
|
||||
// Move composite filters to the top, since they usually match lower number of time series.
|
||||
// Move regexp filters to the bottom, since they require scanning all the entries for the given label.
|
||||
isCompositeA := tf.isComposite()
|
||||
isCompositeB := tf.isComposite()
|
||||
if isCompositeA != isCompositeB {
|
||||
return isCompositeA
|
||||
}
|
||||
if tf.matchCost != other.matchCost {
|
||||
return tf.matchCost < other.matchCost
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user