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

about RANGE COLUMNS partitioning:partition clipping does not take effect #32626

Closed
WholeWorld-Timothy opened this issue Feb 25, 2022 · 11 comments · Fixed by #32721
Closed

about RANGE COLUMNS partitioning:partition clipping does not take effect #32626

WholeWorld-Timothy opened this issue Feb 25, 2022 · 11 comments · Fixed by #32721
Assignees
Labels
affects-4.0 This bug affects 4.0.x versions. affects-5.0 This bug affects 5.0.x versions. affects-5.1 This bug affects 5.1.x versions. affects-5.2 This bug affects 5.2.x versions. affects-5.3 This bug affects 5.3.x versions. affects-5.4 This bug affects 5.4.x versions. component/tablepartition This issue is related to Table Partition of TiDB. severity/major sig/planner SIG: Planner type/bug The issue is confirmed as a bug.

Comments

@WholeWorld-Timothy
Copy link

WholeWorld-Timothy commented Feb 25, 2022

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

1.create table like:

CREATE TABLE test.table_day (
summ_date varchar (8) NOT NULL
)
PARTITION BY RANGE COLUMNS (summ_date)
( PARTITION prt_before VALUES LESS THAN (“20210101”),
PARTITION prt_20210101 VALUES LESS THAN (“20210102”),
PARTITION prt_20210102 VALUES LESS THAN (“20210103”))
  1. execute sql like:
    explain select * from test.table_day where summ_date in (“20210101”,“20210102”);

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

id                    |estRows |task     |access object                          |operator info                                       |
----------------------+--------+---------+---------------------------------------+----------------------------------------------------+
PartitionUnion_9      |60.00   |root     |                                       |                                                    |
├─TableReader_12      |20.00   |root     |                                       |data:Selection_11                                   |
│ └─Selection_11      |20.00   |cop[tikv]|                                       |in(test.table_day.summ_date, "20210101", "20210102")|
│   └─TableFullScan_10|10000.00|cop[tikv]|table:table_day, partition:prt_before  |keep order:false, stats:pseudo                      |
├─TableReader_15      |20.00   |root     |                                       |data:Selection_14                                   |
│ └─Selection_14      |20.00   |cop[tikv]|                                       |in(test.table_day.summ_date, "20210101", "20210102")|
│   └─TableFullScan_13|10000.00|cop[tikv]|table:table_day, partition:prt_20210101|keep order:false, stats:pseudo                      |
└─TableReader_18      |20.00   |root     |                                       |data:Selection_17                                   |
  └─Selection_17      |20.00   |cop[tikv]|                                       |in(test.table_day.summ_date, "20210101", "20210102")|
    └─TableFullScan_16|10000.00|cop[tikv]|table:table_day, partition:prt_20210102|keep order:false, stats:pseudo                      |

All partitions are scanned

3. What did you see instead (Required)

partition clipping is performed at query time

4. What is your TiDB version? (Required)

5.4.0

@WholeWorld-Timothy WholeWorld-Timothy added the type/bug The issue is confirmed as a bug. label Feb 25, 2022
@aytrack aytrack added component/tablepartition This issue is related to Table Partition of TiDB. severity/major sig/sql-infra SIG: SQL Infra labels Feb 28, 2022
@ti-chi-bot ti-chi-bot added may-affects-4.0 This bug maybe affects 4.0.x versions. may-affects-5.0 This bug maybe affects 5.0.x versions. may-affects-5.1 This bug maybe affects 5.1.x versions. may-affects-5.2 This bug maybe affects 5.2.x versions. may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-5.4 This bug maybe affects 5.4.x versions. labels Feb 28, 2022
@jebter jebter added the affects-5.4 This bug affects 5.4.x versions. label Feb 28, 2022
@ti-chi-bot ti-chi-bot removed the may-affects-5.4 This bug maybe affects 5.4.x versions. label Feb 28, 2022
@zimulala zimulala added sig/planner SIG: Planner and removed sig/sql-infra SIG: SQL Infra labels Mar 1, 2022
@mjonss
Copy link
Contributor

mjonss commented Mar 1, 2022

The issue does not affect int partitioning columns and seems only to be affecting IN with multiple values.

@mjonss
Copy link
Contributor

mjonss commented Mar 1, 2022

Only int and time type pruning for IN is currently implemented for RANGE COLUMNS partitioning.

@WholeWorld-Timothy
Copy link
Author

Can partition clipping be implemented for VARCHAR or other string types for RANGE COLUMNS partitioning?There are a number of cases in our enterprise that require this implementation.

@mjonss
Copy link
Contributor

mjonss commented Mar 1, 2022

@WholeWorld-Timothy yes it can be implemented, it is fairly simple to do, but it also needs testing with different collations etc.

What character set and collation do you use (so I can add tests for them)?

@WholeWorld-Timothy
Copy link
Author

We use the default character set and collation rules: utf8mb4, utf8mb4_bin
Thank you very much for your help

@mjonss
Copy link
Contributor

mjonss commented Mar 1, 2022

/label affects-5.3

@ti-chi-bot ti-chi-bot added affects-5.3 This bug affects 5.3.x versions. and removed may-affects-5.3 This bug maybe affects 5.3.x versions. labels Mar 1, 2022
@mjonss
Copy link
Contributor

mjonss commented Mar 1, 2022

/assign @mjonss

@mjonss
Copy link
Contributor

mjonss commented Mar 1, 2022

/label affects-5.2

@ti-chi-bot ti-chi-bot added affects-5.2 This bug affects 5.2.x versions. and removed may-affects-5.2 This bug maybe affects 5.2.x versions. labels Mar 1, 2022
@mjonss
Copy link
Contributor

mjonss commented Mar 1, 2022

/label affects-5.1

@ti-chi-bot ti-chi-bot added the affects-5.1 This bug affects 5.1.x versions. label Mar 1, 2022
@ti-chi-bot ti-chi-bot removed the may-affects-5.1 This bug maybe affects 5.1.x versions. label Mar 1, 2022
@mjonss
Copy link
Contributor

mjonss commented Mar 1, 2022

/label affects-5.0

@ti-chi-bot ti-chi-bot added affects-5.0 This bug affects 5.0.x versions. and removed may-affects-5.0 This bug maybe affects 5.0.x versions. labels Mar 1, 2022
@mjonss
Copy link
Contributor

mjonss commented Mar 1, 2022

/label affects-4.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-4.0 This bug affects 4.0.x versions. affects-5.0 This bug affects 5.0.x versions. affects-5.1 This bug affects 5.1.x versions. affects-5.2 This bug affects 5.2.x versions. affects-5.3 This bug affects 5.3.x versions. affects-5.4 This bug affects 5.4.x versions. component/tablepartition This issue is related to Table Partition of TiDB. severity/major sig/planner SIG: Planner type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants