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: enhanced index range calculation plan #21834

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

xiaodong-ji
Copy link
Contributor

@xiaodong-ji xiaodong-ji commented Dec 16, 2020

What problem does this PR solve?

Issue Number: close #21280

Problem Summary: unexpected selection in index-look-up's build-side after add a probe-side condition.

What is changed and how it works?

What's Changed:

How it Works:

Related changes

Tests

  • Manual test
CREATE TABLE `t` (
  `a` int(11) DEFAULT NULL,
  `b` int(11) DEFAULT NULL,
  `c` int(11) DEFAULT NULL,
  `d` int(11) DEFAULT NULL,
  KEY `kk` (`a`,`b`,`c`)
)
analyze table t;

mysql> explain select * from t where a = 1 and ((b = 1 and c = 1) or (b = 3)) and d = 3;
+-------------------------------+---------+-----------+----------------------------+----------------------------------------------------------------+
| id                            | estRows | task      | access object              | operator info                                                  |
+-------------------------------+---------+-----------+----------------------------+----------------------------------------------------------------+
| IndexLookUp_11                | 0.00    | root      |                            |                                                                |
| ├─IndexRangeScan_8(Build)     | 0.00    | cop[tikv] | table:t, index:kk(a, b, c) | range:[1 1 1,1 1 1], [1 3,1 3], keep order:false, stats:pseudo |
| └─Selection_10(Probe)         | 0.00    | cop[tikv] |                            | eq(test.t.d, 3)                                                |
|   └─TableRowIDScan_9          | 0.00    | cop[tikv] | table:t                    | keep order:false, stats:pseudo                                 |
+-------------------------------+---------+-----------+----------------------------+----------------------------------------------------------------+
4 rows in set (0.00 sec)

CREATE TABLE `tt` (
  `a` int(11) DEFAULT NULL,
  `b` int(11) DEFAULT NULL,
  `c` int(11) DEFAULT NULL,
  `d` int(11) DEFAULT NULL,
  KEY `kk` (`a`,`b`,`c`,`d`)
)

mysql> explain select * from tt where a = 1 and ((b = 1 and c = 1) or (b = 3)) and d = 3; 
+--------------------------+---------+-----------+--------------------------------+--------------------------------------------------------------------+
| id                       | estRows | task      | access object                  | operator info                                                      |
+--------------------------+---------+-----------+--------------------------------+--------------------------------------------------------------------+
| IndexReader_7            | 0.00    | root      |                                | index:Selection_6                                                  |
| └─Selection_6            | 0.00    | cop[tikv] |                                | eq(test.tt.d, 3)                                                   |
|   └─IndexRangeScan_5     | 0.00    | cop[tikv] | table:tt, index:kk(a, b, c, d) | range:[1 1 1 3,1 1 1 3], [1 3,1 3], keep order:false, stats:pseudo |
+--------------------------+---------+-----------+--------------------------------+--------------------------------------------------------------------+
3 rows in set (0.00 sec)

Release note

  • enhancement index range calculation plan

@xiaodong-ji xiaodong-ji requested a review from a team as a code owner December 16, 2020 07:32
@xiaodong-ji xiaodong-ji requested review from SunRunAway and removed request for a team December 16, 2020 07:32
@github-actions github-actions bot added the sig/planner SIG: Planner label Dec 16, 2020
@XuHuaiyu XuHuaiyu added type/bugfix This PR fixes a bug. type/enhancement The issue or PR belongs to an enhancement. and removed type/bugfix This PR fixes a bug. labels Dec 16, 2020
@xiaodong-ji xiaodong-ji changed the title planner: enhancement index range calculation plan planner: enhanced index range calculation plan Dec 16, 2020
Copy link
Contributor

@Reminiscent Reminiscent left a comment

Choose a reason for hiding this comment

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

It's better to add some comments to explain the logic of the code. Thanks!

@Reminiscent
Copy link
Contributor

/run-all-tests

@Reminiscent
Copy link
Contributor

/run-all-tests

@xiaodong-ji
Copy link
Contributor Author

/run-all-tests

@xiaodong-ji
Copy link
Contributor Author

/run-all-tests

@xiaodong-ji
Copy link
Contributor Author

/run-all-tests

@ti-chi-bot ti-chi-bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Feb 22, 2021
@ti-chi-bot ti-chi-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 16, 2021
@ti-chi-bot
Copy link
Member

@xiaodong-ji: PR needs rebase.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. sig/planner SIG: Planner size/M Denotes a PR that changes 30-99 lines, ignoring generated files. type/enhancement The issue or PR belongs to an enhancement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

unexpected selection in index-look-up's build-side after add a probe-side condition
5 participants