Skip to content

sql/opt: add session setting to disable merged partial stats use in opt#126948

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
Uzair5162:add-opt-use-merged-stats-setting-95233
Jul 11, 2024
Merged

sql/opt: add session setting to disable merged partial stats use in opt#126948
craig[bot] merged 1 commit intocockroachdb:masterfrom
Uzair5162:add-opt-use-merged-stats-setting-95233

Conversation

@Uzair5162
Copy link
Copy Markdown
Contributor

Previously, any merged stats created from existing partial stats would always be used by the optimizer. Adds the
optimizer_use_merged_partial_statistics session setting, which can be used to disable merged stat usage in the optimizer. This is now disabled by default. Merged stats will still be created in the stats cache if partial stats exist, and the creation of partial stats can be controlled using the enable_create_stats_using_extremes session setting.

Fixes: #95233

See also: #125950

Release note (sql change): Added a session setting, optimizer_use_merged_partial_statistics, which can be set to true to enable usage of existing partial statistics merged with full statistics when optimizing a query, which is disabled by default.

Previously, any merged stats created from existing partial stats
would always be used by the optimizer. Adds the
`optimizer_use_merged_partial_statistics` session setting, which can be
used to disable merged stat usage in the optimizer. This is now disabled
by default. Merged stats will still be created in the stats cache if
partial stats exist, and the creation of partial stats can be controlled
using the `enable_create_stats_using_extremes` session setting.

Fixes: cockroachdb#95233

See also: cockroachdb#125950

Release note (sql change): Added a session setting,
`optimizer_use_merged_partial_statistics`, which can be set to true to
enable usage of existing partial statistics merged with full statistics
when optimizing a query, which is disabled by default.
@Uzair5162 Uzair5162 requested a review from DrewKimball July 10, 2024 19:52
@Uzair5162 Uzair5162 requested a review from a team as a code owner July 10, 2024 19:52
@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

Copy link
Copy Markdown
Contributor Author

@Uzair5162 Uzair5162 left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @DrewKimball)


pkg/sql/vars.go line 843 at r1 (raw file):

			return formatBoolAsPostgresSetting(evalCtx.SessionData().OptimizerUseMergedPartialStatistics), nil
		},
		GlobalDefault: globalFalse,

I decided to make this disabled by default to be consistent with enable_create_stats_using_extremes.

Copy link
Copy Markdown
Collaborator

@DrewKimball DrewKimball left a comment

Choose a reason for hiding this comment

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

:lgtm: Nice!

Reviewed 11 of 11 files at r1, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained

@Uzair5162
Copy link
Copy Markdown
Contributor Author

bors r+

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Jul 11, 2024

@craig craig bot merged commit 55f7f58 into cockroachdb:master Jul 11, 2024
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.

sql/stats: add variables to disable partial statistics merging and usage

3 participants