-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
28892: opt: reorganize selectivity calculations r=RaduBerinde a=RaduBerinde #### opt: add disable flag to opttester Add a flag to norm/opt that disables specific rules. Release note: None #### opt: add testcases showing stats problem Release note: None #### opt: reorganize selectivity calculations Fixing a few issues with selectivity calculations, related to the handling of constraints in conjunction with equivalencies. In principle, applying the filter `a=10 AND a=b` should result in similar stats with applying `a=10` and then applying `a=b` but this was not the case. Changes: - We were updating the distinct counts to take into account the equivalencies before we estimated selectivity. This can lead to the selectivity of some constraints effectively being applied twice. The call to applyEquivalencies is moved after the selectivity calculations. - When calculating selectivity from distinct counts we were taking into account equivalencies, even though we later apply the selectivity of equivalencies separately. The fix is to only look at the distinct count of each column, rather than taking the minimum across the equivalency group. - When calculating selectivity for equivalency, we were looking at the "input" distinct counts. But if some distinct counts were updated by a constraint, we want to use the updated values; so the code now checks `ColStats` first. An example with some intuition for this: when applying a filter `a=10 AND a=b`, the behavior should be the same with first applying filter `a=10` and then applying `a=b`. So the "input" to the equivalency calculation needs to reflect `a=10`. - Finally, another difference when handling a conjunction is that we only calculate RowCount and bound the distinct counts at the end. We now update the RowCount "in step" with Selectivity; in addition, RowCount is used as an upper bound when consulting "input" stats. Release note: None Co-authored-by: Radu Berinde <[email protected]>
- Loading branch information
Showing
8 changed files
with
348 additions
and
183 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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.