Skip to content

parser: add several optimizer hints#424

Merged
foreyes merged 6 commits into
pingcap:masterfrom
foreyes:dev/rewrite_hints
Aug 14, 2019
Merged

parser: add several optimizer hints#424
foreyes merged 6 commits into
pingcap:masterfrom
foreyes:dev/rewrite_hints

Conversation

@foreyes
Copy link
Copy Markdown
Contributor

@foreyes foreyes commented Aug 1, 2019

What problem does this PR solve?

Add optimizer hints.

What is changed and how it works?

Change TableOptimizerHint struct, change parser.y, add tests.

Check List

Tests

  • Unit test

Code changes

  • Has exported struct change

Related changes

@foreyes foreyes added the WIP label Aug 1, 2019
@foreyes foreyes force-pushed the dev/rewrite_hints branch 2 times, most recently from 208793b to c85b15d Compare August 2, 2019 06:42
@codecov
Copy link
Copy Markdown

codecov Bot commented Aug 2, 2019

Codecov Report

Merging #424 into master will decrease coverage by 0.18%.
The diff coverage is 4.76%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #424      +/-   ##
==========================================
- Coverage   70.66%   70.48%   -0.19%     
==========================================
  Files          32       32              
  Lines        7436     7456      +20     
==========================================
  Hits         5255     5255              
- Misses       1666     1686      +20     
  Partials      515      515
Impacted Files Coverage Δ
parser.go 70.58% <ø> (ø) ⬆️
misc.go 96.42% <ø> (ø) ⬆️
ast/misc.go 70.85% <4.76%> (-1.55%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e92cb39...59e3040. Read the comment docs.

@codecov
Copy link
Copy Markdown

codecov Bot commented Aug 2, 2019

Codecov Report

Merging #424 into master will decrease coverage by 0.04%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #424      +/-   ##
==========================================
- Coverage   71.12%   71.07%   -0.05%     
==========================================
  Files          32       32              
  Lines        7542     7540       -2     
==========================================
- Hits         5364     5359       -5     
- Misses       1662     1665       +3     
  Partials      516      516
Impacted Files Coverage Δ
misc.go 96.42% <ø> (ø) ⬆️
parser.go 70.58% <ø> (ø) ⬆️
ast/misc.go 74.05% <100%> (+0.49%) ⬆️
ast/ddl.go 78.5% <0%> (-0.52%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5f07200...0a13108. Read the comment docs.

@foreyes foreyes force-pushed the dev/rewrite_hints branch from 99ef044 to 71ccd47 Compare August 8, 2019 02:52
@foreyes foreyes force-pushed the dev/rewrite_hints branch 5 times, most recently from f4e7abd to c36e23c Compare August 8, 2019 08:03
@foreyes
Copy link
Copy Markdown
Contributor Author

foreyes commented Aug 8, 2019

Now only TIDB_HJ, TIDB_INLJ, TIDB_SMJ, HASH_JOIN, INL_JOIN, SM_JOIN, HASH_AGG, STREAM_AGG are in use. We can ignore other hints at this moment.

And integration test fails because it rely on pingcap/tidb#11673.
We should merge this first, and then merge TiDB PR.

@foreyes foreyes force-pushed the dev/rewrite_hints branch from c36e23c to 554c383 Compare August 8, 2019 08:18
Comment thread parser.y
$$ = getUint64FromNUM($1)
case "g":
$$ = getUint64FromNUM($1) * 1024
default:
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Do we have better way to do this?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why not add a syntax for memory unit? Or you cannot raise the right warnings since the quota maybe 0M.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Since syntax start with number and contains a-zA-Z is difficult to handle, we may not be able to use syntax like 233M. And in my opinion, M and G should not become a keyword, so...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

0M is a good case

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

now we can use MEMORY_QUOTA(233 M)

@foreyes foreyes requested review from alivxxx and lzmhhh123 August 8, 2019 08:24
@foreyes
Copy link
Copy Markdown
Contributor Author

foreyes commented Aug 8, 2019

PTAL. @lzmhhh123 @lamxTyler

@foreyes foreyes removed the WIP label Aug 8, 2019
@foreyes foreyes changed the title [WIP] parser: add several optimizer hints parser: add several optimizer hints Aug 8, 2019
Comment thread misc.go
"IS": is,
"ISSUER": issuer,
"ISOLATION": isolation,
"USE_TOJA": hintUseToja,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What is toja?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Convert in subquery into inner join and aggregation. Seems like this one.
The name is advised by product team.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

How about adding a comment for this abbreviation.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Okay, and I will contact PM team also.

Comment thread parser.y
{
$$ = &ast.TableOptimizerHint{HintName: model.NewCIStr($1)}
}
| hintNoIndexMerge
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why it cannot specify table names?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It's just a switch to disable this optimizer rule.
Also advised by product team...

Comment thread ast/misc.go Outdated
Comment thread parser.y
Comment thread misc.go
"IS": is,
"ISSUER": issuer,
"ISOLATION": isolation,
"USE_TOJA": hintUseToja,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

How about adding a comment for this abbreviation.

Comment thread parser.y
{
$$ = &ast.TableOptimizerHint{HintName: model.NewCIStr($1)}
}
| hintReadConsistentReplica
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this one enforce table read from follower or learner?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Does it also need a table list?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is depend on TiKV. It will not be used in 4.0GA, so it's just a draft.

Copy link
Copy Markdown
Contributor Author

@foreyes foreyes Aug 12, 2019

Choose a reason for hiding this comment

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

It's about read from follower, but it's not clear to enforce, advise or enable.

Comment thread parser.y
$$ = false
}

HintQueryType:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

how about change:

Suggested change
HintQueryType:
HintSQLType:

Copy link
Copy Markdown
Contributor Author

@foreyes foreyes Aug 12, 2019

Choose a reason for hiding this comment

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

You mean change hint name from "query_type" into "sql_type" ?

@foreyes foreyes force-pushed the dev/rewrite_hints branch 7 times, most recently from 05bad36 to 9df303f Compare August 13, 2019 07:04
@foreyes
Copy link
Copy Markdown
Contributor Author

foreyes commented Aug 13, 2019

PTAL. @lzmhhh123 @lamxTyler .
We can ignore problems about hint name or hint arguments now.
Those are decided by PM team, and many won't be used in 4.0GA. Some of them are just draft.
Integration test fails because it rely on TiDB PR pingcap/tidb#11673

@foreyes foreyes requested review from alivxxx and lzmhhh123 August 13, 2019 07:31
Copy link
Copy Markdown
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

@foreyes foreyes added the status/LGT1 LGT1 label Aug 14, 2019
@lzmhhh123
Copy link
Copy Markdown
Contributor

@foreyes pls resolve the conflicts, then LGTM.

@foreyes foreyes force-pushed the dev/rewrite_hints branch from 9df303f to 0a13108 Compare August 14, 2019 07:15
@foreyes foreyes merged commit 43d2d68 into pingcap:master Aug 14, 2019
@foreyes foreyes deleted the dev/rewrite_hints branch August 14, 2019 11:32
foreyes added a commit to foreyes/parser that referenced this pull request Sep 16, 2019
tiancaiamao pushed a commit to tiancaiamao/parser that referenced this pull request Apr 27, 2021
lyonzhi pushed a commit to lyonzhi/parser that referenced this pull request Apr 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants