mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
lib/storage: do not re-calculate stats for heavy tag filters
This should reduce the number of slow queries when stats for heavy tag filters was recalculated.
This commit is contained in:
parent
48656dcc38
commit
388cdb1980
1 changed files with 6 additions and 3 deletions
|
@ -2797,9 +2797,12 @@ func (is *indexSearch) getMetricIDsForDateAndFilters(date uint64, tfs *TagFilter
|
||||||
tf := &tfs.tfs[i]
|
tf := &tfs.tfs[i]
|
||||||
loopsCount, lastQueryTimestamp := is.getLoopsCountAndTimestampForDateFilter(date, tf)
|
loopsCount, lastQueryTimestamp := is.getLoopsCountAndTimestampForDateFilter(date, tf)
|
||||||
origLoopsCount := loopsCount
|
origLoopsCount := loopsCount
|
||||||
if currentTime > lastQueryTimestamp+60*60 {
|
if currentTime > lastQueryTimestamp+3*3600 {
|
||||||
// Reset loopsCount to 0 every hour for collecting updated stats for the tf.
|
// Update stats once per 3 hours only for relatively fast tag filters.
|
||||||
loopsCount = 0
|
// There is no need in spending CPU resources on updating stats for slow tag filters.
|
||||||
|
if loopsCount <= 10e6 {
|
||||||
|
loopsCount = 0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if loopsCount == 0 {
|
if loopsCount == 0 {
|
||||||
// Prevent from possible thundering herd issue when heavy tf is executed from multiple concurrent queries
|
// Prevent from possible thundering herd issue when heavy tf is executed from multiple concurrent queries
|
||||||
|
|
Loading…
Reference in a new issue