Planner generate `IndexRangeScan`/`TableRangeScan` instead of `TableDual`
- 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)
```
drop table if exists t, t1;
CREATE TABLE `t` ( `COL1` int NOT NULL, PRIMARY KEY (`COL1`));
explain select min(col1) from t where col1 > 2147483647;
CREATE TABLE `t1` ( `COL1` int NOT NULL, PRIMARY KEY (`COL1`) /*T![clustered_index] NONCLUSTERED */ );
explain select min(col1) from t1 where col1 > 2147483647;
```
### 2. What did you expect to see? (Required)
```
mysql> explain select min(col1) from t where col1 > 2147483648;
+----------------------+---------+------+---------------+----------------------------------+
| id | estRows | task | access object | operator info |
+----------------------+---------+------+---------------+----------------------------------+
| StreamAgg_10 | 1.00 | root | | funcs:min(test.t.col1)->Column#6 |
| └─Limit_14 | 1.00 | root | | offset:0, count:1 |
| └─TableDual_18 | 3333.33 | root | | rows:0 |
+----------------------+---------+------+---------------+----------------------------------+
3 rows in set (0.00 sec)
```
### 3. What did you see instead (Required)
```
mysql> explain select min(col1) from t where col1 > 2147483647;
+-------------------------------+---------+-----------+---------------+--------------------------------------------------------+
| id | estRows | task | access object | operator info |
+-------------------------------+---------+-----------+---------------+--------------------------------------------------------+
| StreamAgg_10 | 1.00 | root | | funcs:min(test.t.col1)->Column#2 |
| └─Limit_14 | 1.00 | root | | offset:0, count:1 |
| └─TableReader_21 | 1.00 | root | | data:Limit_20 |
| └─Limit_20 | 1.00 | cop[tikv] | | offset:0, count:1 |
| └─TableRangeScan_19 | 1.00 | cop[tikv] | table:t | range:(2147483647,+inf], keep order:true, stats:pseudo |
+-------------------------------+---------+-----------+---------------+--------------------------------------------------------+
5 rows in set (0.00 sec)
mysql> explain select min(col1) from t1 where col1 > 2147483647;
+-------------------------------+---------+-----------+-------------------------------+--------------------------------------------------------+
| id | estRows | task | access object | operator info |
+-------------------------------+---------+-----------+-------------------------------+--------------------------------------------------------+
| StreamAgg_10 | 1.00 | root | | funcs:min(test.t1.col1)->Column#3 |
| └─Limit_14 | 1.00 | root | | offset:0, count:1 |
| └─IndexReader_21 | 1.00 | root | | index:Limit_20 |
| └─Limit_20 | 1.00 | cop[tikv] | | offset:0, count:1 |
| └─IndexRangeScan_19 | 1.00 | cop[tikv] | table:t1, index:PRIMARY(COL1) | range:(2147483647,+inf], keep order:true, stats:pseudo |
+-------------------------------+---------+-----------+-------------------------------+--------------------------------------------------------+
5 rows in set (0.00 sec)
```
### 4. What is your TiDB version? (Required)
Contributor guide
Assessment
This issue has not been assessed yet.