-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
*: improve performance of show variables #5297
Changes from 12 commits
e16c54e
1e04fa8
a993b7a
4a8e3a6
91ddd51
f231d94
d73a664
3ae328f
821f2e6
5c3e77a
fb9e3f5
38dcd8a
a590ffa
c89897a
ddf9eea
0af2e84
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -594,6 +594,25 @@ func (s *session) getExecRet(ctx context.Context, sql string) (string, error) { | |
return value, nil | ||
} | ||
|
||
// GetAllSysVars implements GlobalVarAccessor.GetAllSysVars interface. | ||
func (s *session) GetAllSysVars() (map[string]string, error) { | ||
if s.Value(context.Initing) != nil { | ||
return nil, nil | ||
} | ||
sql := `SELECT VARIABLE_NAME, VARIABLE_VALUE FROM %s.%s;` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why should we load all global variables from tikv? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This makes no difference for performance, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I care about the performance, not the memory consuming. We only need to load the variables that in the |
||
sql = fmt.Sprintf(sql, mysql.SystemDB, mysql.GlobalVariablesTable) | ||
rows, _, err := s.ExecRestrictedSQL(s, sql) | ||
if err != nil { | ||
return nil, errors.Trace(err) | ||
} | ||
ret := make(map[string]string) | ||
for _, r := range rows { | ||
k, v := r.GetString(0), r.GetString(1) | ||
ret[k] = v | ||
} | ||
return ret, nil | ||
} | ||
|
||
// GetGlobalSysVar implements GlobalVarAccessor.GetGlobalSysVar interface. | ||
func (s *session) GetGlobalSysVar(name string) (string, error) { | ||
if s.Value(context.Initing) != nil { | ||
|
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.
add some comment here. about session scope, global scope and none scope, it is confused.