Skip to content
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

EXTRACT(YEAR FROM col) partitioning expression does not prune partitions #54210

Closed
mjonss opened this issue Jun 25, 2024 · 0 comments · Fixed by #54209
Closed

EXTRACT(YEAR FROM col) partitioning expression does not prune partitions #54210

mjonss opened this issue Jun 25, 2024 · 0 comments · Fixed by #54209
Labels
affects-5.4 This bug affects the 5.4.x(LTS) versions. affects-6.1 This bug affects the 6.1.x(LTS) versions. affects-6.5 This bug affects the 6.5.x(LTS) versions. affects-7.1 This bug affects the 7.1.x(LTS) versions. affects-7.5 This bug affects the 7.5.x(LTS) versions. affects-8.1 This bug affects the 8.1.x(LTS) versions. component/tablepartition This issue is related to Table Partition of TiDB. severity/major sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.

Comments

@mjonss
Copy link
Contributor

mjonss commented Jun 25, 2024

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

create table t (a datetime, b varchar(255)) partition by range (extract(year from a)) (partition p2020 values less than (2021), partition p2021 values less than (2022), partition pMax values less than (maxvalue));
insert into t values ('2020-12-31 23:59:59','2020-12-31 23:59:59'),('2021-01-01', '2021-01-01');
explain select * from t where a = '2020-12-31 23:59:59';

2. What did you expect to see? (Required)

That only partition p2020 would be used.

tidb> explain select * from t where a = '2020-12-31 23:59:59';
+-------------------------+----------+-----------+-----------------+------------------------------------------+
| id                      | estRows  | task      | access object   | operator info                            |
+-------------------------+----------+-----------+-----------------+------------------------------------------+
| TableReader_7           | 10.00    | root      | partition:p2020 | data:Selection_6                         |
| └─Selection_6       | 10.00    | cop[tikv] |                 | eq(test.t.a, 2020-12-31 23:59:59.000000) |
|   └─TableFullScan_5 | 10000.00 | cop[tikv] | table:t         | keep order:false, stats:pseudo           |
+-------------------------+----------+-----------+-----------------+------------------------------------------+

3. What did you see instead (Required)

All partitions where used.

tidb> explain select * from t where a = '2020-12-31 23:59:59';
+-------------------------+----------+-----------+---------------+------------------------------------------+
| id                      | estRows  | task      | access object | operator info                            |
+-------------------------+----------+-----------+---------------+------------------------------------------+
| TableReader_7           | 10.00    | root      | partition:all | data:Selection_6                         |
| └─Selection_6       | 10.00    | cop[tikv] |               | eq(test.t.a, 2020-12-31 23:59:59.000000) |
|   └─TableFullScan_5 | 10000.00 | cop[tikv] | table:t       | keep order:false, stats:pseudo           |
+-------------------------+----------+-----------+---------------+------------------------------------------+

4. What is your TiDB version? (Required)

tidb_version(): Release Version: v8.1.0
Edition: Community
Git Commit Hash: 945d07c5d5c7a1ae212f6013adfb187f2de24b23
Git Branch: HEAD
UTC Build Time: 2024-05-21 03:52:40
GoVersion: go1.21.10
Race Enabled: false
Check Table Before Drop: false
Store: tikv
@mjonss mjonss added the type/bug The issue is confirmed as a bug. label Jun 25, 2024
@jebter jebter added the component/tablepartition This issue is related to Table Partition of TiDB. label Jun 28, 2024
@mjonss mjonss added affects-8.1 This bug affects the 8.1.x(LTS) versions. affects-7.5 This bug affects the 7.5.x(LTS) versions. affects-7.1 This bug affects the 7.1.x(LTS) versions. affects-5.4 This bug affects the 5.4.x(LTS) versions. affects-6.1 This bug affects the 6.1.x(LTS) versions. affects-6.5 This bug affects the 6.5.x(LTS) versions. and removed may-affects-8.1 may-affects-7.5 may-affects-7.1 may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-6.1 may-affects-6.5 labels Jul 2, 2024
ti-chi-bot bot pushed a commit that referenced this issue Aug 2, 2024
ti-chi-bot bot pushed a commit that referenced this issue Aug 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-5.4 This bug affects the 5.4.x(LTS) versions. affects-6.1 This bug affects the 6.1.x(LTS) versions. affects-6.5 This bug affects the 6.5.x(LTS) versions. affects-7.1 This bug affects the 7.1.x(LTS) versions. affects-7.5 This bug affects the 7.5.x(LTS) versions. affects-8.1 This bug affects the 8.1.x(LTS) versions. component/tablepartition This issue is related to Table Partition of TiDB. severity/major sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants