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

planner: cardinality estimation on TPCC customer is not accurate enough #39636

Open
qw4990 opened this issue Dec 5, 2022 · 0 comments
Open
Labels
epic/cardinality-estimation the optimizer cardinality estimation sig/planner SIG: Planner type/enhancement The issue or PR belongs to an enhancement.

Comments

@qw4990
Copy link
Contributor

qw4990 commented Dec 5, 2022

Enhancement

replayer.zip

The estimation result of the composite condition c_w_id=? and c_d_id=? and c_last=? is over-estimated and causes a wrong plan(should use IndexLookUp here).
image

The root cause is our current exponential estimation algorithm(https://github.com/pingcap/tidb/blob/master/statistics/index.go#L324) cannot fit TPCC workload(Customer) well.
This algorithm assume all input columns have relatively high correlation, but c_w_id, c_d_id and c_last break this assumption.

If the cardinality is correct, the planner can select the right plan:
image

@qw4990 qw4990 added type/enhancement The issue or PR belongs to an enhancement. sig/planner SIG: Planner epic/cardinality-estimation the optimizer cardinality estimation labels Dec 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
epic/cardinality-estimation the optimizer cardinality estimation sig/planner SIG: Planner type/enhancement The issue or PR belongs to an enhancement.
Projects
None yet
Development

No branches or pull requests

1 participant