opt: add settings to enable usage of histograms and multi-column stats #48105
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.
Prior to this commit, histograms and multi-column stats were always used
by the optimizer for cardinality estimation if they were available. This
commit adds two new session settings along with two corresponding cluster
settings to control whether or not the optimizer should use histograms or
multi-column stats.
Note that even if the settings are enabled, the optimizer cannot use these
statistics if they haven't been collected. Collection of histograms and
multi-column stats is still controlled by the existing cluster settings
sql.stats.histogram_collection.enabled
andsql.stats.multi_column_collection.enabled
.The new settings to control usage by the optimizer are:
Cluster settings:
Session settings:
Both settings are enabled by default.
Fixes #43308
Informs #38082
Informs #34422
Release note (sql change): Added two new session settings and corresponding
cluster settings to control whether the optimizer uses histograms and
multi-column statistics for cardinality estimation. The session settings
are optimizer_use_histograms and optimizer_use_multicol_stats, with
corresponding cluster settings sql.defaults.optimizer_use_histograms.enabled
and sql.defaults.optimizer_use_multicol_stats.enabled. Both settings are
enabled by default.