Planner: Incorrect estRows on Projection with PointGet
- Dominant language
- Go
- Stars
- 40.5k
- Forks
- 6.2k
- PR merge metrics
- PR metrics pending
Description
## Bug Report
When a parent LogicalProjection derives statistics, it copies the child’s RowCount in DeriveStats. Later in physical optimization, the plan may be rewritten by ConvertToPointGet, which updates the child’s stats.RowCount (e.g., to 1 for PointGet). However, the parent Projection’s previously copied RowCount is not refreshed, so its estRows becomes inconsistent with the child and remains significantly larger. This leads to wrong cost, sub-optimal plan choice, and misleading EXPLAIN output (parent shows thousands of rows while the child is Point_Get with 1 row).
### 1. Minimal reproduce step (Required)
### 2. What did you expect to see? (Required)
```
mysql> EXPLAIN SELECT *
FROM t1
WHERE url IN ('') AND is_active = 1;
+-------------------+---------+------+---------------------------+-------------------+
| id | estRows | task | access object | operator info |
+-------------------+---------+------+---------------------------+-------------------+
| Projection_4 | 1.00 | root | | ... |
| └─Point_Get_5 | 1.00 | root | table:t1, index:...| |
+-------------------+---------+------+---------------------------+-------------------+
```
### 3. What did you see instead (Required)
```
mysql> EXPLAIN SELECT *
FROM t1
WHERE url IN ('') AND is_active = 1;
+-------------------+---------+------+---------------------------+-------------------+
| id | estRows | task | access object | operator info |
+-------------------+---------+------+---------------------------+-------------------+
| Projection_4 | 1286.63 | root | | ... |
| └─Point_Get_5 | 1.00 | root | table:t1, index:...| |
+-------------------+---------+------+---------------------------+-------------------+
```
### 4. What is your TiDB version? (Required)
v8.5.2
Contributor guide
Assessment
This issue has not been assessed yet.