cannot prune partition by PARTITION BY RANGE (TO_DAYS(`c_datetime`))
- 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 `t1` (
`c_datetime` datetime NOT NULL,
`c1` int DEFAULT NULL,
`c2` int DEFAULT NULL,
PRIMARY KEY (`c_datetime`) /*T![clustered_index] NONCLUSTERED */,
KEY `c1` (`c1`),
KEY `c2` (`c2`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
PARTITION BY RANGE (TO_DAYS(`c_datetime`))
(PARTITION `p0` VALUES LESS THAN (737821),
PARTITION `p1` VALUES LESS THAN (737881),
PARTITION `p2` VALUES LESS THAN (737942),
PARTITION `p3` VALUES LESS THAN (MAXVALUE))
explain select * from t1 where to_days(t1.c_datetime) <737821
```
### 2. What did you expect to see? (Required)
```
+---------------------+----------+-----------+---------------+-----------------------------------------+
| id | estRows | task | access object | operator info |
+---------------------+----------+-----------+---------------+-----------------------------------------+
| Selection_7 | 8000.00 | root | | lt(to_days(test.t1.c_datetime), 737821) |
| └─TableReader_6 | 10000.00 | root | partition:p0 | data:TableFullScan_5 |
| └─TableFullScan_5 | 10000.00 | cop[tikv] | table:t1 | keep order:false, stats:pseudo |
+---------------------+----------+-----------+---------------+-----------------------------------------+
```
### 3. What did you see instead (Required)
```
+---------------------+----------+-----------+---------------+-----------------------------------------+
| id | estRows | task | access object | operator info |
+---------------------+----------+-----------+---------------+-----------------------------------------+
| Selection_7 | 8000.00 | root | | lt(to_days(test.t1.c_datetime), 737821) |
| └─TableReader_6 | 10000.00 | root | partition:all | data:TableFullScan_5 |
| └─TableFullScan_5 | 10000.00 | cop[tikv] | table:t1 | keep order:false, stats:pseudo |
+---------------------+----------+-----------+---------------+-----------------------------------------+
```
### 4. What is your TiDB version? (Required)
Contributor guide
Assessment
This issue has not been assessed yet.