-
Notifications
You must be signed in to change notification settings - Fork 5.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
stats: auto analyze on certain period of a day #7570
Conversation
a36c514
to
b1e8881
Compare
Can we let it auto analyze at |
@winoros Yes, you can set it to |
Could we guarantee that the EndTime is latter than the StartTime? |
statistics/update_test.go
Outdated
tbl *statistics.Table | ||
ratio float64 | ||
limit time.Duration | ||
timeStr []string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would easier to read if we split timeStr
slice to start
, end
and now
.
@lamxTyler |
@shenli Then it would need another field to note that they are not on the same day, I think it is more complicated. |
@coocood Stats owner could on any server, so it may introduce unexpected behavior when the stats owner is on a different timezone. |
Whether analyze it or not is still controlled by the existing variable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
@winoros Yes, |
@lamxTyler |
statistics/update.go
Outdated
return now.Sub(end) <= 0 || now.Sub(start) >= 0 | ||
} | ||
|
||
// NeedAnalyzeTable checks if we need to analyze the table: | ||
// 1. If the table has never been analyzed, we need to analyze it when it has | ||
// not been modified for a time. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/ not been modified for a time./ not been modified for a while
statistics/update_test.go
Outdated
now: "00:02 CST", | ||
result: false, | ||
}, | ||
// table already analyzed and but not within time period |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/table already analyzed and but not within time period/table was already analyzed and but not within time period
and for the rest of the comment, you also need to fix them.
@coocood How can the stats owner know the timezone of the server that sets the variable? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
LGTM |
/run-all-tests |
What problem does this PR solve?
Some application doesn't want auto-analyze to be executed in the hours when the cluster is busy, we need to provide an option to only execute auto-analyze in idle hours.
Fix #7072
What is changed and how it works?
Add two global variables to control the analyze start time and end time. But when the table is never analyzed, the time limit is ignored.
Check List
Tests
Code changes
Side effects
Related changes
PTAL @coocood @zz-jason @winoros