pingcap / pingcap/tidb

planner: cardinality estimation on TPCC customer is not accurate enough

Open
#39,636 0 comments 0 reactions 0 assignees View on GitHub
epic/cardinality-estimation sig/planner type/enhancement
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).
![image](https://user-images.githubusercontent.com/7499936/205624417-9fea78d0-37eb-43d3-bc01-64c62cca2c84.png)

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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.