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

planner/core: support range partition pruning for 'in' expression (#17210) #17318

Merged
merged 4 commits into from Jun 1, 2020

Conversation

sre-bot
Copy link
Contributor

@sre-bot sre-bot commented May 20, 2020

cherry-pick #17210 to release-3.0


What problem does this PR solve?

create table t1 (a int)  partition by range (a) (
    partition p0 values less than (10),
    partition p1 values less than (20),
    partition p2 values less than (30),
    partition p3 values less than (40),
    partition p4 values less than MAXVALUE
);

explain select * from t1 where a in (20, 21, 22, 23, 24, 25);
+------------------------+----------+-----------+------------------------+---------------------------------------+
| id                     | estRows  | task      | access object          | operator info                         |
+------------------------+----------+-----------+------------------------+---------------------------------------+
| Union_11               | 300.00   | root      |                        |                                       |
| ├─TableReader_14       | 60.00    | root      |                        | data:Selection_13                     |
| │ └─Selection_13       | 60.00    | cop[tikv] |                        | in(test.t1.a, 20, 21, 22, 23, 24, 25) |
| │   └─TableFullScan_12 | 10000.00 | cop[tikv] | table:t1, partition:p0 | keep order:false, stats:pseudo        |
| ├─TableReader_17       | 60.00    | root      |                        | data:Selection_16                     |
| │ └─Selection_16       | 60.00    | cop[tikv] |                        | in(test.t1.a, 20, 21, 22, 23, 24, 25) |
| │   └─TableFullScan_15 | 10000.00 | cop[tikv] | table:t1, partition:p1 | keep order:false, stats:pseudo        |
| ├─TableReader_20       | 60.00    | root      |                        | data:Selection_19                     |
| │ └─Selection_19       | 60.00    | cop[tikv] |                        | in(test.t1.a, 20, 21, 22, 23, 24, 25) |
| │   └─TableFullScan_18 | 10000.00 | cop[tikv] | table:t1, partition:p2 | keep order:false, stats:pseudo        |
| ├─TableReader_23       | 60.00    | root      |                        | data:Selection_22                     |
| │ └─Selection_22       | 60.00    | cop[tikv] |                        | in(test.t1.a, 20, 21, 22, 23, 24, 25) |
| │   └─TableFullScan_21 | 10000.00 | cop[tikv] | table:t1, partition:p3 | keep order:false, stats:pseudo        |
| └─TableReader_26       | 60.00    | root      |                        | data:Selection_25                     |
|   └─Selection_25       | 60.00    | cop[tikv] |                        | in(test.t1.a, 20, 21, 22, 23, 24, 25) |
|     └─TableFullScan_24 | 10000.00 | cop[tikv] | table:t1, partition:p4 | keep order:false, stats:pseudo        |
+------------------------+----------+-----------+------------------------+---------------------------------------+

Problem Summary:

Our current partition pruning doesn't handle the in expression.

What is changed and how it works?

Proposal: xxx

What's Changed:

Support range partition pruning for 'in' expression

How it Works:

x in (1, 2) can be treat as x = 1 or x = 2 ...

Related changes

  • Need to cherry-pick to the release branch

Check List

Tests

  • Integration test

Release note

  • Support range partition pruning for 'in' expression

Signed-off-by: sre-bot <sre-bot@pingcap.com>
@sre-bot
Copy link
Contributor Author

sre-bot commented May 20, 2020

/run-all-tests

@sre-bot sre-bot added sig/planner SIG: Planner priority/release-blocker This PR blocks a release. Please review it ASAP. type/3.0-cherry-pick type/bug-fix This PR fixes a bug. labels May 20, 2020
@sre-bot sre-bot added this to the v3.0.15 milestone May 20, 2020
@imtbkcat
Copy link

@tiancaiamao please fix conflict

@tiancaiamao
Copy link
Contributor

/run-all-tests

@tiancaiamao
Copy link
Contributor

/run-all-tests tidb-test=pr/1059

@tiancaiamao
Copy link
Contributor

/run-all-tests tidb-test=pr/1059

Copy link
Contributor

@XuHuaiyu XuHuaiyu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link

@imtbkcat imtbkcat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@bb7133 bb7133 merged commit 8e59b33 into pingcap:release-3.0 Jun 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/expression priority/release-blocker This PR blocks a release. Please review it ASAP. sig/planner SIG: Planner type/bug-fix This PR fixes a bug. type/3.0-cherry-pick
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants