mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
lib/storage: tune the logic for sorting tag filters according the their exeuction times
This commit is contained in:
parent
1a19702d92
commit
9d1f14d94c
1 changed files with 12 additions and 14 deletions
|
@ -2811,23 +2811,21 @@ func (is *indexSearch) getMetricIDsForDateAndFilters(date uint64, tfs *TagFilter
|
||||||
}
|
}
|
||||||
tfws := make([]tagFilterWithWeight, len(tfs.tfs))
|
tfws := make([]tagFilterWithWeight, len(tfs.tfs))
|
||||||
ct := fasttime.UnixTimestamp()
|
ct := fasttime.UnixTimestamp()
|
||||||
|
hasDurationReset := false
|
||||||
for i := range tfs.tfs {
|
for i := range tfs.tfs {
|
||||||
tf := &tfs.tfs[i]
|
tf := &tfs.tfs[i]
|
||||||
durationSeconds, lastQueryTimestamp := is.getDurationAndTimestampForDateFilter(date, tf)
|
durationSeconds, lastQueryTimestamp := is.getDurationAndTimestampForDateFilter(date, tf)
|
||||||
if ct > lastQueryTimestamp+60 {
|
if durationSeconds == 0 && (tf.isNegative || tf.isRegexp && len(tf.orSuffixes) == 0) {
|
||||||
// It is time to update filter duration stats.
|
// Negative and regexp filters usually take the most time, so move them to the end of filters
|
||||||
if tf.isNegative || tf.isRegexp && len(tf.orSuffixes) == 0 {
|
// in the hope they won't be executed at all.
|
||||||
// Negative and regexp filters usually take the most time, so move them to the end of filters
|
durationSeconds = 10
|
||||||
// in the hope they won't be executed at all.
|
is.storeDurationAndTimestampForDateFilter(date, tf, durationSeconds, 0)
|
||||||
if durationSeconds == 0 {
|
}
|
||||||
durationSeconds = 10
|
if !hasDurationReset && ct > lastQueryTimestamp+10*60 && durationSeconds < 0.2 {
|
||||||
}
|
// Reset duration stats for relatively fast filters, so it is re-populated below.
|
||||||
} else {
|
// Reset duration for a single filter at a time in order to reduce negative impact on query time.
|
||||||
// Reset duration stats for relatively fast {key="value"} and {key=~"foo|bar|baz"} filters, so it is re-populated below.
|
durationSeconds = 0
|
||||||
if durationSeconds < 0.5 {
|
hasDurationReset = true
|
||||||
durationSeconds = 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
tfws[i] = tagFilterWithWeight{
|
tfws[i] = tagFilterWithWeight{
|
||||||
tf: tf,
|
tf: tf,
|
||||||
|
|
Loading…
Reference in a new issue