Dongpo Liu
Dongpo Liu
A simple rust script to reproduce it: ```rust #!/usr/bin/env -S cargo +nightly -Zscript ---cargo [dependencies] sqlx = { version = "0.7", features = ["mysql", "runtime-tokio-native-tls"] } tokio = { version...
> 1. In this case, `Selectivity()` can't correctly match the stats to the filters. It should prefer stats on (iabc) for estimation, but finally chooses stats on (ib). [GetUsableSetsByGreedy](https://github.com/pingcap/tidb/blob/f5ac1c4a453f9983355404b70cc10a9610353c03/pkg/planner/cardinality/selectivity.go#L599) ```go...
The steps: 1. [`GetUsableSetsByGreedy` uses incorrect statistics to estimate the selectivity of the indexes.](https://github.com/pingcap/tidb/blob/854a4e3303003e3f8c1151da27e539337dcf8277/pkg/planner/core/logical_plans.go#L1599-L1601) 2. [`deriveIndexPathStats` employs an unperfect algorithm to update the `CountAfterAccess`.](https://github.com/pingcap/tidb/blob/854a4e3303003e3f8c1151da27e539337dcf8277/pkg/planner/core/logical_plans.go#L1599-L1601) 3. [`skylinePruning` prunes the ib index...
/hold Better to add a unit test to cover it. Thank you!
> I took another look at this issue. It might be that there is an inconsistency in behavior between the integration test and the actual run. ~~Good catch! Yes. I...
The way to reproduce this issue on the real cluster is to execute all SQL together. If you are quick enough, then you can reproduce this issue.
We created some nil histograms here: https://github.com/pingcap/tidb/blob/c5882b1f6c58b4ccbfdc63233f2221d4808748a7/pkg/statistics/handle/globalstats/global_stats_async.go#L422
/hold I think we should remove the previous unnecessary changes and wait for others to review the new changes before merging.
Also, please update the PR description and PR title to summarize what has been done and how it works. Thank you.
I will try to improve it.