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

opt: add settings to enable usage of histograms and multi-column stats #48105

Merged
merged 1 commit into from
Apr 28, 2020

Conversation

rytaft
Copy link
Collaborator

@rytaft rytaft commented Apr 28, 2020

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 and
sql.stats.multi_column_collection.enabled.

The new settings to control usage by the optimizer are:

Cluster settings:

sql.defaults.optimizer_use_histograms.enabled
sql.defaults.optimizer_use_multicol_stats.enabled

Session settings:

optimizer_use_histograms
optimizer_use_multicol_stats

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.

@rytaft rytaft requested a review from RaduBerinde April 28, 2020 13:40
@rytaft rytaft requested a review from a team as a code owner April 28, 2020 13:40
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@rytaft rytaft force-pushed the settings branch 2 times, most recently from a1540a7 to 0df8d94 Compare April 28, 2020 13:46
Copy link
Member

@RaduBerinde RaduBerinde left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @RaduBerinde and @rytaft)


pkg/sql/exec_util.go, line 193 at r1 (raw file):

var optUseHistogramsClusterMode = settings.RegisterBoolSetting(
	"sql.defaults.optimizer_use_histograms.enabled",
	"default value for optimizer_use_histograms session setting; enables usage of histograms in the optimizer by default",

add a note that it doesn't disable collection, and mention the other setting for the collection


pkg/sql/exec_util.go, line 199 at r1 (raw file):

var optUseMultiColStatsClusterMode = settings.RegisterBoolSetting(
	"sql.defaults.optimizer_use_multicol_stats.enabled",
	"default value for optimizer_use_multicol_stats session setting; enables usage of multi-column stats in the optimizer by default",

ditto

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` and
`sql.stats.multi_column_collection.enabled`.

The new settings to control usage by the optimizer are:

Cluster settings:
```
sql.defaults.optimizer_use_histograms.enabled
sql.defaults.optimizer_use_multicol_stats.enabled
```

Session settings:
```
optimizer_use_histograms
optimizer_use_multicol_stats
```

Both settings are enabled by default.

Fixes cockroachdb#43308
Informs cockroachdb#38082
Informs cockroachdb#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.
Copy link
Collaborator Author

@rytaft rytaft left a comment

Choose a reason for hiding this comment

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

TFTR!

bors r+

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (and 1 stale)


pkg/sql/exec_util.go, line 193 at r1 (raw file):

Previously, RaduBerinde wrote…

add a note that it doesn't disable collection, and mention the other setting for the collection

Done.


pkg/sql/exec_util.go, line 199 at r1 (raw file):

Previously, RaduBerinde wrote…

ditto

Done.

@craig
Copy link
Contributor

craig bot commented Apr 28, 2020

Build succeeded

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

opt: make it possible to selectively disable histogram use
3 participants