-
Notifications
You must be signed in to change notification settings - Fork 6.2k
planner: unexpected low out-of-range estimation on index stats #64572
Copy link
Copy link
Closed
Labels
affects-7.5This bug affects the 7.5.x(LTS) versions.This bug affects the 7.5.x(LTS) versions.affects-8.1This bug affects the 8.1.x(LTS) versions.This bug affects the 8.1.x(LTS) versions.affects-8.5This bug affects the 8.5.x(LTS) versions.This bug affects the 8.5.x(LTS) versions.epic/cardinality-estimationthe optimizer cardinality estimationthe optimizer cardinality estimationreport/customerCustomers have encountered this bug.Customers have encountered this bug.severity/majorsig/plannerSIG: PlannerSIG: Plannertype/bugThe issue is confirmed as a bug.The issue is confirmed as a bug.type/regression
Metadata
Metadata
Assignees
Labels
affects-7.5This bug affects the 7.5.x(LTS) versions.This bug affects the 7.5.x(LTS) versions.affects-8.1This bug affects the 8.1.x(LTS) versions.This bug affects the 8.1.x(LTS) versions.affects-8.5This bug affects the 8.5.x(LTS) versions.This bug affects the 8.5.x(LTS) versions.epic/cardinality-estimationthe optimizer cardinality estimationthe optimizer cardinality estimationreport/customerCustomers have encountered this bug.Customers have encountered this bug.severity/majorsig/plannerSIG: PlannerSIG: Plannertype/bugThe issue is confirmed as a bug.The issue is confirmed as a bug.type/regression
Bug Report
Please answer these questions before submitting your issue. Thanks!
1. Minimal reproduce step (Required)
Reach out me to get the internal plan replayer file.
See the case below, the estimation is extremely low:
This issue was accidentally introduced by #55600.
Before this PR, for index out-of-range estimation, we'll just use the index stats directly.
After this PR, if it's a single-column predicate, we'll use its corresponding column Histogram, which seems a reasonable Improvement.
But the problem is that this column's NDV is small, all values are collected into TopN, so it has no Histogram, which leads to the extreme estimation.
2. What did you expect to see? (Required)
Before that PR, the estimation seems acceptable.

3. What did you see instead (Required)
Extremely low estimation.
4. What is your TiDB version? (Required)
After #55600