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: create a special type for selectivity to clean up stats code #53860

Closed
rytaft opened this issue Sep 2, 2020 · 0 comments · Fixed by #59413 or #60012
Closed

opt: create a special type for selectivity to clean up stats code #53860

rytaft opened this issue Sep 2, 2020 · 0 comments · Fixed by #59413 or #60012
Assignees
Labels
A-sql-optimizer SQL logical planning and optimizations. C-cleanup Tech debt, refactors, loose ends, etc. Solution not expected to significantly change behavior.

Comments

@rytaft
Copy link
Collaborator

rytaft commented Sep 2, 2020

As described in this comment:

I'm wondering if it makes sense to create a special type for selectivities (maybe just an alias for float64), with a function on the type that multiplies two selectivities but ensures if both are non-zero that the result is non-zero. This would avoid the duplicated logic and hopefully make it harder for someone in the future to forget to add this logic to new code that multiplies selectivities together.

@rytaft rytaft added C-cleanup Tech debt, refactors, loose ends, etc. Solution not expected to significantly change behavior. A-sql-optimizer SQL logical planning and optimizations. labels Sep 2, 2020
@rytaft rytaft self-assigned this Sep 2, 2020
angelazxu added a commit to angelazxu/cockroach that referenced this issue Jan 26, 2021
Previously, the selectivity of a filter was represented by a float64 type.
There were several places in the statistics code where range checks were
being performed to ensure selectivity was between (0,1].

This change cleans up the statistics code and creates a Selectivity type with
custom methods to replace direct numerical operations, incorporating the range
check to ensure all operations on selectivity return a valid value.

As a result of implementing these changes, there are slight changes to some
values in the test files. The query plans and performance mostly stay the same.

Resolves: cockroachdb#53860

Release note: None
angelazxu added a commit to angelazxu/cockroach that referenced this issue Jan 28, 2021
Previously, the selectivity of a filter was represented by a float64 type.
There were several places in the statistics code where range checks were
being performed to ensure selectivity was between (0,1].

This change cleans up the statistics code and creates a Selectivity type with
custom methods to replace direct numerical operations, incorporating the range
check to ensure all operations on selectivity return a valid value.

As a result of implementing these changes, there are slight changes to some
values in the test files. The query plans and performance mostly stay the same.

Resolves: cockroachdb#53860

Release note: None
angelazxu added a commit to angelazxu/cockroach that referenced this issue Feb 1, 2021
Previously, the selectivity of a filter was represented by a float64 type.
There were several places in the statistics code where range checks were
being performed to ensure selectivity was between (0,1].

This change cleans up the statistics code and creates a Selectivity type with
custom methods to replace direct numerical operations, incorporating the range
check to ensure all operations on selectivity return a valid value.

As a result of implementing these changes, there are slight changes to some
values in the test files. The query plans and performance mostly stay the same.

Resolves: cockroachdb#53860

Release note: None
angelazxu added a commit to angelazxu/cockroach that referenced this issue Feb 2, 2021
Previously, the selectivity of a filter was represented by a float64 type.
There were several places in the statistics code where range checks were
being performed to ensure selectivity was between (0,1].

This change cleans up the statistics code and creates a Selectivity type with
custom methods to replace direct numerical operations, incorporating the range
check to ensure all operations on selectivity return a valid value.

As a result of implementing these changes, there are slight changes to some
values in the test files. The query plans and performance mostly stay the same.

Resolves: cockroachdb#53860

Release note: None
angelazxu added a commit to angelazxu/cockroach that referenced this issue Feb 3, 2021
Previously, the selectivity of a filter was represented by a float64 type.
There were several places in the statistics code where range checks were
being performed to ensure selectivity was between (0,1].

This change cleans up the statistics code and creates a Selectivity type with
custom methods to replace direct numerical operations, incorporating the range
check to ensure all operations on selectivity return a valid value.

As a result of implementing these changes, there are slight changes to some
values in the test files. The query plans and performance mostly stay the same.

Resolves: cockroachdb#53860

Release note: None
angelazxu added a commit to angelazxu/cockroach that referenced this issue Feb 3, 2021
Previously, the selectivity of a filter was represented by a float64 type.
There were several places in the statistics code where range checks were
being performed to ensure selectivity was between (0,1].

This change cleans up the statistics code and creates a Selectivity type with
custom methods to replace direct numerical operations, incorporating the range
check to ensure all operations on selectivity return a valid value.

As a result of implementing these changes, there are slight changes to some
values in the test files. The query plans and performance mostly stay the same.

Resolves: cockroachdb#53860

Release note: None
craig bot pushed a commit that referenced this issue Feb 4, 2021
59413: opt: create a special type for selectivity to clean up stats code r=angelazxu a=angelazxu

Previously, the selectivity of a filter was represented by a float64 type.
There were several places in the statistics code where range checks were
being performed to ensure selectivity was between (0,1].

This change cleans up the statistics code and creates a Selectivity type with
custom methods to replace direct numerical operations, incorporating the range
check to ensure all operations on selectivity return a valid value.

As a result of implementing these changes, there are slight changes to some
values in the test files. The query plans and performance mostly stay the same.

Resolves: #53860

Release note: None

Co-authored-by: Angela Xu <[email protected]>
@craig craig bot closed this as completed in 1c31782 Feb 4, 2021
angelazxu added a commit to angelazxu/cockroach that referenced this issue Feb 8, 2021
The fraction function in the statistics builder code was only being used to
construct Selectivity, used inside the MakeSelectivity method.

This change moves the logic from the fraction function into the code for
Selectivity. It is an additional clean-up to cockroachdb#59413, to get rid of direct
numerical operations on Selectivity.

Fixes: cockroachdb#53860

Release note: None
angelazxu added a commit to angelazxu/cockroach that referenced this issue Feb 8, 2021
The fraction function in the statistics builder code was only being used to
construct Selectivity, used inside the MakeSelectivity method.

This change moves the logic from the fraction function into the code for
Selectivity. It is an additional clean-up to cockroachdb#59413, to get rid of direct
numerical operations on Selectivity.

Fixes: cockroachdb#53860

Release note: None
craig bot pushed a commit that referenced this issue Feb 8, 2021
60012: opt: move fraction function from statistics code to selectivity r=angelazxu a=angelazxu

The fraction function in the statistics builder code was only being used to
construct Selectivity, used inside the MakeSelectivity method.

This change moves the logic from the fraction function into the code for
Selectivity. It is an additional clean-up to #59413, to get rid of direct
numerical operations on Selectivity.

Fixes: #53860

Release note: None

Co-authored-by: Angela Xu <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-sql-optimizer SQL logical planning and optimizations. C-cleanup Tech debt, refactors, loose ends, etc. Solution not expected to significantly change behavior.
Projects
None yet
1 participant