-
Notifications
You must be signed in to change notification settings - Fork 5.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
partition pruning not effective on date scenarios #19941
Comments
@imtbkcat @tiancaiamao PTAL |
Integrity check: |
This looks mostly fixed, with the exception of TiDB needing to access mysql> EXPLAIN SELECT COUNT(*) FROM t1 WHERE d >= '2018-01-01' AND d < '2019-01-01';
+------------------------------------+----------+-----------+---------------------------+--------------------------------------------------------------------------------------+
| id | estRows | task | access object | operator info |
+------------------------------------+----------+-----------+---------------------------+--------------------------------------------------------------------------------------+
| HashAgg_15 | 1.00 | root | | funcs:count(Column#4)->Column#3 |
| └─PartitionUnion_16 | 2.00 | root | | |
| ├─StreamAgg_31 | 1.00 | root | | funcs:count(Column#6)->Column#4 |
| │ └─TableReader_32 | 1.00 | root | | data:StreamAgg_20 |
| │ └─StreamAgg_20 | 1.00 | cop[tikv] | | funcs:count(1)->Column#6 |
| │ └─Selection_30 | 250.00 | cop[tikv] | | ge(test.t1.d, 2018-01-01 00:00:00.000000), lt(test.t1.d, 2019-01-01 00:00:00.000000) |
| │ └─TableFullScan_29 | 10000.00 | cop[tikv] | table:t1, partition:p2018 | keep order:false, stats:pseudo |
| └─StreamAgg_50 | 1.00 | root | | funcs:count(Column#8)->Column#4 |
| └─TableReader_51 | 1.00 | root | | data:StreamAgg_39 |
| └─StreamAgg_39 | 1.00 | cop[tikv] | | funcs:count(1)->Column#8 |
| └─Selection_49 | 250.00 | cop[tikv] | | ge(test.t1.d, 2018-01-01 00:00:00.000000), lt(test.t1.d, 2019-01-01 00:00:00.000000) |
| └─TableFullScan_48 | 10000.00 | cop[tikv] | table:t1, partition:p2019 | keep order:false, stats:pseudo |
+------------------------------------+----------+-----------+---------------------------+--------------------------------------------------------------------------------------+
12 rows in set (0.00 sec)
mysql> EXPLAIN SELECT COUNT(*) FROM t1 WHERE d >= '2018-01-01' AND d < '2018-12-31';
+----------------------------+---------+-----------+---------------------------+--------------------------------------------------------------------------------------+
| id | estRows | task | access object | operator info |
+----------------------------+---------+-----------+---------------------------+--------------------------------------------------------------------------------------+
| StreamAgg_12 | 1.00 | root | | funcs:count(1)->Column#3 |
| └─TableReader_19 | 0.07 | root | | data:Selection_18 |
| └─Selection_18 | 0.07 | cop[tikv] | | ge(test.t1.d, 2018-01-01 00:00:00.000000), lt(test.t1.d, 2018-12-31 00:00:00.000000) |
| └─TableFullScan_17 | 3.00 | cop[tikv] | table:t1, partition:p2018 | keep order:false, stats:pseudo |
+----------------------------+---------+-----------+---------------------------+--------------------------------------------------------------------------------------+
4 rows in set (0.01 sec)
mysql> EXPLAIN SELECT COUNT(*) FROM t1 WHERE d >= '2018-01-01' AND d <= '2018-12-31';
+----------------------------+---------+-----------+---------------------------+--------------------------------------------------------------------------------------+
| id | estRows | task | access object | operator info |
+----------------------------+---------+-----------+---------------------------+--------------------------------------------------------------------------------------+
| StreamAgg_12 | 1.00 | root | | funcs:count(1)->Column#3 |
| └─TableReader_19 | 0.07 | root | | data:Selection_18 |
| └─Selection_18 | 0.07 | cop[tikv] | | ge(test.t1.d, 2018-01-01 00:00:00.000000), le(test.t1.d, 2018-12-31 00:00:00.000000) |
| └─TableFullScan_17 | 3.00 | cop[tikv] | table:t1, partition:p2018 | keep order:false, stats:pseudo |
+----------------------------+---------+-----------+---------------------------+--------------------------------------------------------------------------------------+
4 rows in set (0.00 sec) |
/info |
Please edit this comment to complete the following informationNot a bug
Duplicate bug
BugNote: Make Sure that 'component', and 'severity' labels are added 1. Root Cause Analysis (RCA) (optional)2. Symptom (optional)3. All Trigger Conditions (optional)4. Workaround (optional)5. Affected versions6. Fixed versions |
Same with dynamic prune mode:
|
The difference between MySQL and TiDB is that MySQL will check the 'transitions' for YEAR() function, so MySQL will prune correctly for |
/component tablepartition |
Bug Report
Please answer these questions before submitting your issue. Thanks!
1. Minimal reproduce step (Required)
2. What did you expect to see? (Required)
In MySQL (see "partitions" column):
3. What did you see instead (Required)
In TiDB (see "access object"):
4. What is your TiDB version? (Required)
The text was updated successfully, but these errors were encountered: