-
Notifications
You must be signed in to change notification settings - Fork 3.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: table setting to turn auto stats collection on/off #78110
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
// Copyright 2022 The Cockroach Authors. | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.txt. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
package catpb | ||
|
||
// AutoStatsCollectionStatus represents whether the auto stats collections | ||
// enabled table setting is enabled, disabled, or not set. | ||
type AutoStatsCollectionStatus int | ||
|
||
// The values for AutoStatsCollectionStatus. | ||
const ( | ||
AutoStatsCollectionNotSet AutoStatsCollectionStatus = iota | ||
AutoStatsCollectionEnabled | ||
AutoStatsCollectionDisabled | ||
) | ||
|
||
const ( | ||
// AutoStatsEnabledSettingName is the name of the automatic stats collection | ||
// enabled cluster setting. | ||
AutoStatsEnabledSettingName = "sql.stats.automatic_collection.enabled" | ||
|
||
// AutoStatsEnabledTableSettingName is the name of the automatic stats | ||
// collection enabled table setting. | ||
AutoStatsEnabledTableSettingName = "sql_stats_automatic_collection_enabled" | ||
|
||
// AutoStatsMinStaleSettingName is the name of the automatic stats collection | ||
// min stale rows cluster setting. | ||
AutoStatsMinStaleSettingName = "sql.stats.automatic_collection.min_stale_rows" | ||
|
||
// UseStatsOnSystemTables is the name of the use statistics on system tables | ||
// cluster setting. | ||
UseStatsOnSystemTables = "sql.stats.system_tables.enabled" | ||
|
||
// AutoStatsMinStaleTableSettingName is the name of the automatic stats collection | ||
// min stale rows table setting. | ||
AutoStatsMinStaleTableSettingName = "sql_stats_automatic_collection_min_stale_rows" | ||
|
||
// AutoStatsFractionStaleSettingName is the name of the automatic stats | ||
// collection fraction stale rows cluster setting. | ||
AutoStatsFractionStaleSettingName = "sql.stats.automatic_collection.fraction_stale_rows" | ||
|
||
// AutoStatsFractionStaleTableSettingName is the name of the automatic stats | ||
// collection fraction stale rows table setting. | ||
AutoStatsFractionStaleTableSettingName = "sql_stats_automatic_collection_fraction_stale_rows" | ||
) | ||
|
||
// AutoStatsCollectionEnabled indicates if automatic statistics collection is | ||
// explicitly enabled or disabled. | ||
func (as *AutoStatsSettings) AutoStatsCollectionEnabled() AutoStatsCollectionStatus { | ||
if as.Enabled == nil { | ||
return AutoStatsCollectionNotSet | ||
} | ||
if *as.Enabled { | ||
return AutoStatsCollectionEnabled | ||
} | ||
return AutoStatsCollectionDisabled | ||
} | ||
|
||
// AutoStatsMinStaleRows indicates the setting of | ||
// sql_stats_automatic_collection_min_stale_rows in AutoStatsSettings. If ok is | ||
// true, then the minStaleRows value is valid, otherwise this has not been set. | ||
func (as *AutoStatsSettings) AutoStatsMinStaleRows() (minStaleRows int64, ok bool) { | ||
if as.MinStaleRows == nil { | ||
return 0, false | ||
} | ||
return *as.MinStaleRows, true | ||
} | ||
|
||
// AutoStatsFractionStaleRows indicates the setting of | ||
// sql_stats_automatic_collection_fraction_stale_rows in AutoStatsSettings. If | ||
// ok is true, then the fractionStaleRows value is valid, otherwise this has not | ||
// been set. | ||
func (as *AutoStatsSettings) AutoStatsFractionStaleRows() (fractionStaleRows float64, ok bool) { | ||
if as.FractionStaleRows == nil { | ||
return 0, false | ||
} | ||
return *as.FractionStaleRows, true | ||
} | ||
|
||
// NoAutoStatsSettingsOverrides is true if no auto stats related table | ||
// settings are present in these AutoStatsSettings. | ||
func (as *AutoStatsSettings) NoAutoStatsSettingsOverrides() bool { | ||
if as.Enabled != nil || | ||
as.MinStaleRows != nil || | ||
as.FractionStaleRows != nil { | ||
return false | ||
} | ||
return true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
nit: comments are usually
Enabled represents ...