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: use a deep copy for accessPath when clone DataSource #13620

Merged
merged 8 commits into from
Nov 20, 2019

Conversation

francis0407
Copy link
Member

What problem does this PR solve?

Before this PR:

mysql> create table t(a int, b int)partition by range columns(a)(partition p0 values less than (10), partition p1 values less than(20), partition p2 values less than(30));
Query OK, 0 rows affected (0.01 sec)

mysql> insert into t values (21, 1), (22, 2), (23, 3), (24, 4), (15, 5);
Query OK, 5 rows affected (0.01 sec)
Records: 5  Duplicates: 0  Warnings: 0

mysql> analyze table t;
Query OK, 0 rows affected (0.01 sec)

mysql> explain select * from t;
+------------------------+----------+-----------+--------------------------------------------------------------------------+
| id                     | count    | task      | operator info                                                            |
+------------------------+----------+-----------+--------------------------------------------------------------------------+
| Union_8                | 10005.00 | root      |                                                                          |
| ├─TableReader_10       | 4.00     | root      | data:TableScan_9                                                         |
| │ └─TableScan_9        | 4.00     | cop[tikv] | table:t, partition:p0, range:[-inf,+inf], keep order:false, stats:pseudo |
| ├─TableReader_12       | 1.00     | root      | data:TableScan_11                                                        |
| │ └─TableScan_11       | 1.00     | cop[tikv] | table:t, partition:p1, range:[-inf,+inf], keep order:false               |
| └─TableReader_14       | 4.00     | root      | data:TableScan_13                                                        |
|   └─TableScan_13       | 4.00     | cop[tikv] | table:t, partition:p2, range:[-inf,+inf], keep order:false               |
+------------------------+----------+-----------+--------------------------------------------------------------------------+
7 rows in set (0.00 sec)

After this PR:

        "SQL": "explain select * from t",
        "Result": [
          "Union_8 10005.00 root ",
          "├─TableReader_10 10000.00 root data:TableScan_9",
          "│ └─TableScan_9 10000.00 cop[tikv] table:t, partition:p0, range:[-inf,+inf], keep order:false, stats:pseudo",
          "├─TableReader_12 1.00 root data:TableScan_11",
          "│ └─TableScan_11 1.00 cop[tikv] table:t, partition:p1, range:[-inf,+inf], keep order:false",
          "└─TableReader_14 4.00 root data:TableScan_13",
          "  └─TableScan_13 4.00 cop[tikv] table:t, partition:p2, range:[-inf,+inf], keep order:false"
        ]

What is changed and how it works?

When processing partition tables, we use a shallow copy for DataSouces. But accessPaths in DataSouces will be changed after that. So we need a deep copy here.

Check List

Tests

  • Unit test

Related changes

  • Need to cherry-pick to the release branch

Release note

  • Fix partition table use wrong stats info in physical optimization.

@francis0407 francis0407 added type/bugfix This PR fixes a bug. sig/planner SIG: Planner labels Nov 20, 2019
@francis0407
Copy link
Member Author

/run-all-tests

Copy link
Member

@winoros winoros left a comment

Choose a reason for hiding this comment

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

lgtm

@francis0407
Copy link
Member Author

/rebuild

@francis0407 francis0407 requested a review from eurekaka November 20, 2019 07:26
@codecov
Copy link

codecov bot commented Nov 20, 2019

Codecov Report

Merging #13620 into master will increase coverage by 0.0404%.
The diff coverage is n/a.

@@               Coverage Diff                @@
##             master     #13620        +/-   ##
================================================
+ Coverage   79.9522%   79.9927%   +0.0404%     
================================================
  Files           473        473                
  Lines        115724     115988       +264     
================================================
+ Hits          92524      92782       +258     
+ Misses        15944      15942         -2     
- Partials       7256       7264         +8

Copy link
Contributor

@eurekaka eurekaka left a comment

Choose a reason for hiding this comment

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

LGTM

@eurekaka eurekaka added the status/can-merge Indicates a PR has been approved by a committer. label Nov 20, 2019
@sre-bot
Copy link
Contributor

sre-bot commented Nov 20, 2019

Your auto merge job has been accepted, waiting for 13621, 13470

@sre-bot
Copy link
Contributor

sre-bot commented Nov 20, 2019

/run-all-tests

@francis0407 francis0407 merged commit 8a4c016 into pingcap:master Nov 20, 2019
@francis0407
Copy link
Member Author

/run-cherry-picker

@sre-bot
Copy link
Contributor

sre-bot commented Nov 20, 2019

cherry pick to release-2.1 in PR #13627

@sre-bot
Copy link
Contributor

sre-bot commented Nov 20, 2019

cherry pick to release-3.0 in PR #13628

XiaTianliang pushed a commit to XiaTianliang/tidb that referenced this pull request Dec 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sig/planner SIG: Planner status/can-merge Indicates a PR has been approved by a committer. type/bugfix This PR fixes a bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants