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: skip virtual generated column in analyze push down #10623

Merged
merged 2 commits into from
May 29, 2019
Merged

planner: skip virtual generated column in analyze push down #10623

merged 2 commits into from
May 29, 2019

Conversation

lonng
Copy link
Contributor

@lonng lonng commented May 28, 2019

Signed-off-by: Lonng heng@lonng.org

What problem does this PR solve?

The virtual column will not store any data in TiKV, so it should be ignored in analyze.

What is changed and how it works?

Filter virtual generated column when push down analyze.

Check List

Tests

  • Unit test

  • Integration test

  • Manually test

  • Before fix:

     mysql> CREATE TABLE contacts2 (     id INT AUTO_INCREMENT PRIMARY KEY,     first_name VARCHAR(50) NOT NULL,     last_name VARCHAR(50) NOT NULL,     fullname varchar(101) GENERATED ALWAYS AS (CONCAT(first_name,' ',last_name)) virtual not null,     email VARCHAR(100) NOT NULL );
     Query OK, 0 rows affected (0.11 sec)
     
     mysql> INSERT INTO contacts2(first_name,last_name, email) VALUES('john','doe','john.doe@mysqltutorial.org');
     Query OK, 1 row affected (0.02 sec)
     
     mysql> analyze table contacts2;
     ERROR 1105 (HY000): other error: [src/coprocessor/dag/executor/mod.rs:161]: column 4 of 1 is missing
    
  • After fix:

     mysql> CREATE TABLE contacts2 (     id INT AUTO_INCREMENT PRIMARY KEY,     first_name VARCHAR(50) NOT NULL,     last_name VARCHAR(50) NOT NULL,     fullname varchar(101) GENERATED ALWAYS AS (CONCAT(first_name,' ',last_name)) virtual not null,     email VARCHAR(100) NOT NULL );
     Query OK, 0 rows affected (0.11 sec)
     
     mysql> INSERT INTO contacts2(first_name,last_name, email) VALUES('john','doe','john.doe@mysqltutorial.org');
     Query OK, 1 row affected (0.02 sec)
     
     mysql> analyze table contacts2;
     Query OK, 0 rows affected (0.08 sec)
    

Related changes

  • Need to cherry-pick to the release branch

@lonng lonng added type/enhancement The issue or PR belongs to an enhancement. sig/planner SIG: Planner type/2.1 cherry-pick labels May 28, 2019
@alivxxx
Copy link
Contributor

alivxxx commented May 28, 2019

Add test?

@codecov
Copy link

codecov bot commented May 28, 2019

Codecov Report

Merging #10623 into master will decrease coverage by 0.0264%.
The diff coverage is 0%.

@@               Coverage Diff                @@
##             master     #10623        +/-   ##
================================================
- Coverage   77.7226%   77.6962%   -0.0265%     
================================================
  Files           413        413                
  Lines         87515      87465        -50     
================================================
- Hits          68019      67957        -62     
- Misses        14351      14361        +10     
- Partials       5145       5147         +2

@codecov
Copy link

codecov bot commented May 28, 2019

Codecov Report

Merging #10623 into master will increase coverage by 0.0255%.
The diff coverage is 0%.

@@               Coverage Diff                @@
##             master     #10623        +/-   ##
================================================
+ Coverage   77.7126%   77.7381%   +0.0254%     
================================================
  Files           413        413                
  Lines         87507      87468        -39     
================================================
- Hits          68004      67996         -8     
+ Misses        14355      14332        -23     
+ Partials       5148       5140         -8

Signed-off-by: Lonng <heng@lonng.org>
@lonng
Copy link
Contributor Author

lonng commented May 29, 2019

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

@lonng
Copy link
Contributor Author

lonng commented May 29, 2019

/run-integration-common-test tidb-test=pr/827

@lonng
Copy link
Contributor Author

lonng commented May 29, 2019

/run-integration-common-test tidb-test=pr/827

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

Copy link
Contributor

@alivxxx alivxxx left a comment

Choose a reason for hiding this comment

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

LGTM

@alivxxx alivxxx added status/LGT2 Indicates that a PR has LGTM 2. and removed status/all tests passed labels May 29, 2019
@jackysp jackysp merged commit b0058eb into pingcap:master May 29, 2019
@lonng lonng deleted the filter-virtual-col-in-analyze branch May 29, 2019 03:17
db-storage pushed a commit to db-storage/tidb that referenced this pull request May 29, 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/LGT2 Indicates that a PR has LGTM 2. type/enhancement The issue or PR belongs to an enhancement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants