planner: cost trace for Selection in explain results is not correct
- Dominant language
- Go
- Stars
- 40.5k
- Forks
- 6.2k
- PR merge metrics
- PR metrics pending
Description
## Bug Report
Please answer these questions before submitting your issue. Thanks!
### 1. Minimal reproduce step (Required)
```
CREATE TABLE `IDT_20736` (
`COL1` varchar(20) DEFAULT NULL,
`COL2` bit(16) DEFAULT NULL,
`COL3` date DEFAULT NULL,
KEY `U_M_COL` (`COL1`(10),`COL2`,`COL3`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
MySQL [coms]> explain format="verbose" select * from IDT_20736 where col3 = "5486-08-31" and col1 = "韎黩烔飩惏榸紵貫崋媴Dz怫睬笾嶖嘢贃後嚟鳝";
+----------------------------+---------+---------+-----------+--------------------------------------------------+-----------------------------------------------------------------------------------------------------------+
| id | estRows | estCost | task | access object | operator info |
+----------------------------+---------+---------+-----------+--------------------------------------------------+-----------------------------------------------------------------------------------------------------------+
| IndexLookUp_12 | 0.01 | 897.47 | root | | |
| ├─Selection_10(Build) | 0.01 | 0.00 | cop[tikv] | | eq(test.idt_20736.col3, 5486-08-31 00:00:00.000000) |
| │ └─IndexRangeScan_8 | 10.00 | 860.00 | cop[tikv] | table:IDT_20736, index:U_M_COL(COL1, COL2, COL3) | range:["韎黩烔飩惏榸紵貫崋媴","韎黩烔飩惏榸紵貫崋媴"], keep order:false, stats:pseudo |
| └─Selection_11(Probe) | 0.01 | 0.00 | cop[tikv] | | eq(test.idt_20736.col1, "韎黩烔飩惏榸紵貫崋媴Dz怫睬笾嶖嘢贃後嚟鳝") |
| └─TableRowIDScan_9 | 0.01 | 860.00 | cop[tikv] | table:IDT_20736 | keep order:false, stats:pseudo |
+----------------------------+---------+---------+-----------+--------------------------------------------------+-----------------------------------------------------------------------------------------------------------+
5 rows in set (0.01 sec)
```
### 2. What did you expect to see? (Required)
the cost of Selection_10 and Selection_11 shouldn't be 0.
### 3. What did you see instead (Required)
It's 0.
### 4. What is your TiDB version? (Required)
```
Release Version: v5.5.0-alpha
Edition: Community
Git Commit Hash: 171a35486036e8ea5b168c2d4d29f4639df1611d
Git Branch: heads/refs/tags/v5.5.0-alpha
UTC Build Time: 2022-02-20 14:52:57
GoVersion: go1.16.4
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false
```
Contributor guide
Assessment
This issue has not been assessed yet.