Skip to content
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

planner: Introduce a new global variable to control the historical statistics feature #30646

Merged
merged 7 commits into from
Dec 14, 2021
6 changes: 5 additions & 1 deletion sessionctx/variable/sysvar.go
Original file line number Diff line number Diff line change
Expand Up @@ -1205,7 +1205,11 @@ var defaultSysVars = []*SysVar{
{Scope: ScopeSession, Name: PluginDir, Value: "/data/deploy/plugin", GetSession: func(s *SessionVars) (string, error) {
return config.GetGlobalConfig().Plugin.Dir, nil
}},

{Scope: ScopeGlobal, Name: TiDBEnableHistoricalStats, Value: Off, Type: TypeBool, GetGlobal: func(s *SessionVars) (string, error) {
return getTiDBTableValue(s, "tidb_enable_historical_stats", Off)
}, SetGlobal: func(s *SessionVars, val string) error {
return setTiDBTableValue(s, "tidb_enable_historical_stats", val, "Current historical statistics enable status")
}},
/* tikv gc metrics */
{Scope: ScopeGlobal, Name: TiDBGCEnable, Value: On, Type: TypeBool, GetGlobal: func(s *SessionVars) (string, error) {
return getTiDBTableValue(s, "tikv_gc_enable", On)
Expand Down
2 changes: 2 additions & 0 deletions sessionctx/variable/tidb_vars.go
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,8 @@ const (
TiDBGCScanLockMode = "tidb_gc_scan_lock_mode"
// TiDBEnableEnhancedSecurity restricts SUPER users from certain operations.
TiDBEnableEnhancedSecurity = "tidb_enable_enhanced_security"
// TiDBEnableHistoricalStats enables the historical statistics feature (default off)
TiDBEnableHistoricalStats = "tidb_enable_historical_stats"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add some tests for it. You can add them here set_test.go#L43 .

)

// TiDB intentional limits
Expand Down