Skip to content

planner: add index optimizer hint#11746

Merged
sre-bot merged 12 commits into
pingcap:masterfrom
foreyes:dev/add_index_hint
Aug 23, 2019
Merged

planner: add index optimizer hint#11746
sre-bot merged 12 commits into
pingcap:masterfrom
foreyes:dev/add_index_hint

Conversation

@foreyes
Copy link
Copy Markdown
Contributor

@foreyes foreyes commented Aug 15, 2019

What problem does this PR solve?

Support SQL hint use index in comment-style optimizer hint.

What is changed and how it works?

Add new hint field into planbuilder, and add matched ast.IndexHint into ast.TableName when build data source.

mysql> explain select /*+ INDEX(t, c_d_e) */ a from t t1;
+-------------------+----------+------+----------------------------------------------------------------------------+
| id                | count    | task | operator info                                                              |
+-------------------+----------+------+----------------------------------------------------------------------------+
| IndexReader_5     | 10000.00 | root | index:IndexScan_4                                                          |
| └─IndexScan_4     | 10000.00 | cop  | table:t1, index:c, d, e, range:[NULL,+inf], keep order:false, stats:pseudo |
+-------------------+----------+------+----------------------------------------------------------------------------+
2 rows in set (0.00 sec)

Check List

Tests

  • Unit test

@foreyes
Copy link
Copy Markdown
Contributor Author

foreyes commented Aug 15, 2019

/run-all-tests

@foreyes foreyes force-pushed the dev/add_index_hint branch from f9ceb61 to 6b1172a Compare August 15, 2019 05:56
@foreyes foreyes force-pushed the dev/add_index_hint branch from 757952a to 058c273 Compare August 15, 2019 06:28
@codecov
Copy link
Copy Markdown

codecov Bot commented Aug 15, 2019

Codecov Report

Merging #11746 into master will not change coverage.
The diff coverage is n/a.

@@             Coverage Diff             @@
##             master     #11746   +/-   ##
===========================================
  Coverage   81.9727%   81.9727%           
===========================================
  Files           435        435           
  Lines         96027      96027           
===========================================
  Hits          78716      78716           
  Misses        11847      11847           
  Partials       5464       5464

@codecov
Copy link
Copy Markdown

codecov Bot commented Aug 15, 2019

Codecov Report

Merging #11746 into master will decrease coverage by 0.0021%.
The diff coverage is 82.8571%.

@@               Coverage Diff                @@
##             master     #11746        +/-   ##
================================================
- Coverage   81.4277%   81.4256%   -0.0022%     
================================================
  Files           433        433                
  Lines         93193      93220        +27     
================================================
+ Hits          75885      75905        +20     
- Misses        11877      11880         +3     
- Partials       5431       5435         +4

@foreyes
Copy link
Copy Markdown
Contributor Author

foreyes commented Aug 16, 2019

PTAL. @lamxTyler @lzmhhh123

Comment thread planner/core/logical_plan_builder.go Outdated
@foreyes foreyes changed the title [WIP]planner: add index optimizer hint planner: add index optimizer hint Aug 16, 2019
@foreyes foreyes force-pushed the dev/add_index_hint branch from f95468f to d88c67b Compare August 16, 2019 06:58
Comment thread planner/core/logical_plan_builder.go Outdated
Comment thread planner/core/logical_plan_builder.go Outdated
Comment thread planner/core/planbuilder.go Outdated
Comment thread planner/core/logical_plan_builder.go Outdated
Comment thread planner/core/planbuilder.go
@foreyes
Copy link
Copy Markdown
Contributor Author

foreyes commented Aug 19, 2019

/run-all-tests

1 similar comment
@foreyes
Copy link
Copy Markdown
Contributor Author

foreyes commented Aug 19, 2019

/run-all-tests

@foreyes foreyes force-pushed the dev/add_index_hint branch 2 times, most recently from 930d783 to 1a85b8e Compare August 19, 2019 05:49
@foreyes foreyes force-pushed the dev/add_index_hint branch from 1a85b8e to 36614f9 Compare August 20, 2019 02:54
@foreyes foreyes force-pushed the dev/add_index_hint branch from 4c08fbb to bebb8ee Compare August 20, 2019 06:00
Copy link
Copy Markdown
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/LGT1 Indicates that a PR has LGTM 1. label Aug 20, 2019
@foreyes foreyes force-pushed the dev/add_index_hint branch from 6ab722b to 2938767 Compare August 23, 2019 07:31
@foreyes foreyes requested a review from lzmhhh123 August 23, 2019 07:36
@foreyes
Copy link
Copy Markdown
Contributor Author

foreyes commented Aug 23, 2019

/run-all-tests

@foreyes
Copy link
Copy Markdown
Contributor Author

foreyes commented Aug 23, 2019

/run-unit-test

Copy link
Copy Markdown
Contributor

@lzmhhh123 lzmhhh123 left a comment

Choose a reason for hiding this comment

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

LGTM.

@lzmhhh123 lzmhhh123 added status/all tests passed status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Aug 23, 2019
@sre-bot
Copy link
Copy Markdown
Contributor

sre-bot commented Aug 23, 2019

/run-all-tests

@sre-bot sre-bot merged commit cc04cd9 into pingcap:master Aug 23, 2019
@foreyes foreyes deleted the dev/add_index_hint branch August 25, 2019 07:59
foreyes added a commit to foreyes/tidb that referenced this pull request Sep 16, 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. status/LGT2 Indicates that a PR has LGTM 2.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants