planner: cardinality estimation on TPCC customer is not accurate enough
- Dominant language
- Go
- Stars
- 40.5k
- Forks
- 6.2k
- PR merge metrics
- PR metrics pending
Description
## Enhancement
[replayer.zip](https://github.com/pingcap/tidb/files/10153537/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).

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:

Contributor guide
Assessment
This issue has not been assessed yet.