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

stats, plan: return row count 0 for empty range on handle #7583

Merged
merged 1 commit into from
Sep 3, 2018

Conversation

eurekaka
Copy link
Contributor

@eurekaka eurekaka commented Sep 2, 2018

What problem does this PR solve?

to solve #7582

What is changed and how it works?

after this PR:

mysql> create table t1(a int primary key);
Query OK, 0 rows affected (0.11 sec)

mysql> explain select * from t1 where a = 1 and a = 2;
+-------------------+-------+------+------------------------------------------+
| id                | count | task | operator info                            |
+-------------------+-------+------+------------------------------------------+
| TableReader_6     | 0.00  | root | data:TableScan_5                         |
| └─TableScan_5     | 0.00  | cop  | table:t1, keep order:false, stats:pseudo |
+-------------------+-------+------+------------------------------------------+
2 rows in set (0.00 sec)

mysql> analyze table t1;
Query OK, 0 rows affected (0.00 sec)

mysql> explain select * from t1 where a = 1 and a = 2;
+-------------------+-------+------+------------------------------------------+
| id                | count | task | operator info                            |
+-------------------+-------+------+------------------------------------------+
| TableReader_6     | 0.00  | root | data:TableScan_5                         |
| └─TableScan_5     | 0.00  | cop  | table:t1, keep order:false, stats:pseudo |
+-------------------+-------+------+------------------------------------------+
2 rows in set (0.00 sec)

mysql> insert into t1 values(1);
Query OK, 1 row affected (0.00 sec)

mysql> explain select * from t1 where a = 1 and a = 2;
+-------------------+-------+------+------------------------------------------+
| id                | count | task | operator info                            |
+-------------------+-------+------+------------------------------------------+
| TableReader_6     | 0.00  | root | data:TableScan_5                         |
| └─TableScan_5     | 0.00  | cop  | table:t1, keep order:false, stats:pseudo |
+-------------------+-------+------+------------------------------------------+
2 rows in set (0.00 sec)

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

mysql> explain select * from t1 where a = 1 and a = 2;
+-------------------+-------+------+----------------------------+
| id                | count | task | operator info              |
+-------------------+-------+------+----------------------------+
| TableReader_6     | 0.00  | root | data:TableScan_5           |
| └─TableScan_5     | 0.00  | cop  | table:t1, keep order:false |
+-------------------+-------+------+----------------------------+
2 rows in set (0.00 sec)

Check List

Tests

Code changes

  • Has exported function/method change

Related changes

  • Need to cherry-pick to the release branch
  • Need to be included in the release note: return row count zero in explain for table scan with empty range

@eurekaka
Copy link
Contributor Author

eurekaka commented Sep 2, 2018

/run-all-tests

@ngaut
Copy link
Member

ngaut commented Sep 2, 2018

LGTM

@eurekaka eurekaka added status/all tests passed status/LGT1 Indicates that a PR has LGTM 1. labels Sep 3, 2018
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/LGT1 Indicates that a PR has LGTM 1. labels Sep 3, 2018
@alivxxx alivxxx merged commit 621ca43 into pingcap:master Sep 3, 2018
@eurekaka eurekaka deleted the empty_range_selectivity branch September 25, 2018 02:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/statistics sig/planner SIG: Planner status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants