planner: add skew risk ratio for range pred#62035
Conversation
|
Hi @ichen032. Thanks for your PR. I'm waiting for a pingcap member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
Hi @ichen032. Thanks for your PR. PRs from untrusted users cannot be marked as trusted with I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
/ok-to-test |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #62035 +/- ##
================================================
+ Coverage 72.9222% 73.7781% +0.8559%
================================================
Files 1740 1781 +41
Lines 482965 503954 +20989
================================================
+ Hits 352189 371808 +19619
- Misses 109185 109645 +460
- Partials 21591 22501 +910
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
/retest-required |
|
/retest |
mjonss
left a comment
There was a problem hiding this comment.
Please add tests for the new variable.
- That it works as expected.
- That if it is set on Global level, it is inherited by Session level, and setting it on session level will override the global level.
|
/retest |
|
/retest-required |
mjonss
left a comment
There was a problem hiding this comment.
LGTM, only to minor formatting suggestions.
[LGTM Timeline notifier]Timeline:
|
Co-authored-by: Mattias Jonsson <mjonss@users.noreply.github.com>
Co-authored-by: Mattias Jonsson <mjonss@users.noreply.github.com>
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: benmeadowcroft, mjonss, terry1purcell The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
…fix-scalar-func-init * commit '5ec4f36c855574b64be98e4c9f6b4485ceb4143d': (48 commits) dxf: use correct store in add-index, checksum by copr in import-into, and enable DXF service (pingcap#62224) infoschema: Add new fields in tiflash system table (pingcap#62296) lightning: fix panic on checksum manager close when checksum is off (pingcap#62300) *: Add owners cfg file for pkg/metrics module (pingcap#62292) autoid: reserve a table ID range for downstream fork (pingcap#62157) planner: Fix expression rewriting and method signature mismatch in plan cache (pingcap#58506) planner: use prop based noCopPushDown mechanism to replace aggregation field. (pingcap#62249) fix: close issue 59457 by trim compare first (pingcap#61915) planner: add skew risk ratio for range pred (pingcap#62035) meta: unify definition of system or memory DB name (pingcap#62247) ddl: add retry for updateSelfVersion (pingcap#62190) *: upgrade client go to add config valid function (pingcap#62246) executor: fix the inappropriate RequiredRows set by `TopNExec` (pingcap#62154) planner: RegardNULLAsPoint should be true as default (pingcap#62194) planner: apply predicate simplification before extract condition (pingcap#62211) test: fix failed test caused by new version of `mc` (pingcap#61356) planner: deprecate the logical interface CanPushToCop and its implementation canPushToCopImpl. (pingcap#62235) fix: shut down test without error (pingcap#61921) planner: lift the canPushToCop check of logical join/window/selection (pingcap#62206) backend/local: add rate limiter for split region and ingest data (pingcap#61555) ...
What problem does this PR solve?
Issue Number: close #62093
Problem Summary:
What changed and how does it work?
This enhancement adds a new global/session variable tidb_opt_risk_range_skew_ratio that allows users or external processes to adjust how much skew is considered in our range estimation for ranges within a bucket.
When estimating a range predicate that is within a single histogram bucket, we assume even distribution of data within the bucket and so use the fraction of the bucket that our predicate covers * total row count for that bucket. Thus, we don't consider data skew which can be especially problematic with certain data types such as strings, where our data distribution typically has many gaps.
So, we calculate the worst case skew for a range to be the total row count of its bucket (excluding the repeat count of the last value if it is not within the range). Then we use our tidb_opt_risk_range_skew_ratio variable to determine how much of that skew is to be considered in our row estimation. For a default value of 0, there is no change to the original estimate, and when it is 1 , our row estimation = worst case skew.
Check List
Tests
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.