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) #17320

Merged
merged 3 commits into from
May 21, 2020

Conversation

sre-bot
Copy link
Contributor

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

cherry-pick #17210 to release-4.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

@sre-bot sre-bot requested a review from a team as a code owner May 20, 2020 11:30
@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 issue blocks a release. Please solve it ASAP. type/4.0-cherry-pick type/bugfix This PR fixes a bug. labels May 20, 2020
@ghost ghost requested review from eurekaka and removed request for a team May 20, 2020 11:30
@sre-bot sre-bot added this to the v4.0.0-ga milestone May 20, 2020
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
Member

@jackysp jackysp left a comment

Choose a reason for hiding this comment

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

LGTM

@jebter
Copy link

jebter commented May 21, 2020

/merge

@sre-bot sre-bot added the status/can-merge Indicates a PR has been approved by a committer. label May 21, 2020
@sre-bot
Copy link
Contributor Author

sre-bot commented May 21, 2020

/run-all-tests

@sre-bot sre-bot merged commit 115a0fe into pingcap:release-4.0 May 21, 2020
@XuHuaiyu
Copy link
Contributor

XuHuaiyu commented Jun 2, 2020

close #16681

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority/release-blocker This issue blocks a release. Please solve it ASAP. sig/planner SIG: Planner status/can-merge Indicates a PR has been approved by a committer. type/bugfix This PR fixes a bug. type/4.0-cherry-pick
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants