Skip to content

add a table hint to access table from a specific type of storage.#446

Merged
lzmhhh123 merged 8 commits into
pingcap:masterfrom
lzmhhh123:dev/add_hint_for_access_flash
Aug 23, 2019
Merged

add a table hint to access table from a specific type of storage.#446
lzmhhh123 merged 8 commits into
pingcap:masterfrom
lzmhhh123:dev/add_hint_for_access_flash

Conversation

@lzmhhh123
Copy link
Copy Markdown
Contributor

What problem does this PR solve?

At now, tidb need a hint to make table reading from tiflash.

What is changed and how it works?

Add a hint to enforce table reading form tiflash.

Check List

Tests

  • Unit test
  • Integration test

Related changes

  • Need to update the documentation

@codecov
Copy link
Copy Markdown

codecov Bot commented Aug 7, 2019

Codecov Report

Merging #446 into master will increase coverage by 0.02%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #446      +/-   ##
==========================================
+ Coverage   71.61%   71.63%   +0.02%     
==========================================
  Files          32       32              
  Lines        7736     7735       -1     
==========================================
+ Hits         5540     5541       +1     
+ Misses       1671     1670       -1     
+ Partials      525      524       -1
Impacted Files Coverage Δ
parser.go 70.58% <ø> (ø) ⬆️
ast/misc.go 74.32% <100%> (+0.12%) ⬆️
misc.go 96.49% <100%> (+0.06%) ⬆️

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 64bfe3e...7998b80. Read the comment docs.

Comment thread ast/misc.go Outdated
Copy link
Copy Markdown
Contributor

@foreyes foreyes left a comment

Choose a reason for hiding this comment

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

LGTM

Comment thread misc.go Outdated
@foreyes
Copy link
Copy Markdown
Contributor

foreyes commented Aug 8, 2019

Product team advised hint QUERY_TYPE(OLAP/OLTP), is this what you want?

@alivxxx alivxxx removed their request for review August 13, 2019 08:58
@lzmhhh123 lzmhhh123 force-pushed the dev/add_hint_for_access_flash branch 2 times, most recently from 413f67a to fc1c96c Compare August 20, 2019 04:26
@lzmhhh123 lzmhhh123 force-pushed the dev/add_hint_for_access_flash branch from 60fdde9 to c956035 Compare August 20, 2019 05:33
Copy link
Copy Markdown
Member

@winoros winoros 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 changed the title add a table hint to access table from tiflash. add a table hint to access table from a specific type of storage. Aug 20, 2019
Copy link
Copy Markdown
Contributor

@foreyes foreyes left a comment

Choose a reason for hiding this comment

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

rest part lgtm

Comment thread ast/misc.go Outdated
case "memory_quota":
ctx.WritePlainf("%d M", n.MemoryQuota)
case "read_consistent_storage":
ctx.WritePlain(n.StoreType.O)
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.

Suggested change
ctx.WritePlain(n.StoreType.O)
ctx.WritePlain(n.StoreType.String())

Copy link
Copy Markdown
Contributor Author

@lzmhhh123 lzmhhh123 Aug 20, 2019

Choose a reason for hiding this comment

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

If we use String(), it may causes TIFLASH ---> `TIFLASH`. Then the SQL hint will like READ_CONSISTENT_STORAGE(`TIFLASH`[`t1`, `t2`]), that's strange.

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.

Only ctx.WriteName() will add those backquotes. BTW you should use ctx.WriteKeyWord() for case-insensitive keyword-like output.

Copy link
Copy Markdown
Contributor Author

@lzmhhh123 lzmhhh123 Aug 20, 2019

Choose a reason for hiding this comment

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

OKay. Thanks for your advisement. @kennytm

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.

??? I'm confused.

func (cis CIStr) String() string {
	return cis.O
}

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.

@foreyes My fault. I thought you suggested using the WriteName.

Comment thread parser_test.go
Comment thread parser_test.go Outdated
c.Assert(hints[1].Indexes[0].L, Equals, "c1")

// Test READ_CONSISTENT_STORAGE
stmt, _, err = parser.Parse("select /*+ READ_CONSISTENT_STORAGE(tiflash[t1, t2], tikv[t3]) */ c1, c2 from t1, t2, t1 t3 where t1.c1 = t2.c1 and t2.c1 = t3.c1", "", "")
Copy link
Copy Markdown
Contributor

@alivxxx alivxxx Aug 20, 2019

Choose a reason for hiding this comment

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

Why choose this syntax? Why not READ_CONSISTENT_STORAGE(tiflash t1, t2), READ_CONSISTENT_STORAGE(tikv t3) to be consistent with others?

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.

Because we can regard a tiflash[t1, t2] as a whole. If the "query block" also exists in this hint, the hint will like READ_CONSISTENT_STORAGE(@sel1 tiflash t1, t2). That's incomprehensible.

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.

Also seems incomprehensible in this case: READ_CONSISTENT_STORAGE(tiflash[t1, t2], tikv[t3]) ----> READ_CONSISTENT_STORAGE(tiflash t1, t2 tikv t3)

Copy link
Copy Markdown
Contributor

@alivxxx alivxxx Aug 20, 2019

Choose a reason for hiding this comment

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

  • I don't have strong opinion on this specific syntax, but if you decided to group similiar things, it is better to change all others that has similiar syntax, like index and use_index_merge.
  • I think it is quite clear what the comment want to say in READ_CONSISTENT_STORAGE(@sel1 tiflash t1, t2).

Copy link
Copy Markdown
Contributor

@alivxxx alivxxx Aug 20, 2019

Choose a reason for hiding this comment

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

No, just seperate them into two like READ_CONSISTENT_STORAGE(tiflash t1, t2), READ_CONSISTENT_STORAGE(tikv t3).

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.

Hmmm...So may I keep this format? The product manager says that we can only focus on functions. The form is under consideration now.

Comment thread misc.go
Copy link
Copy Markdown
Contributor

@foreyes foreyes 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 20, 2019
@lzmhhh123 lzmhhh123 requested a review from alivxxx August 23, 2019 05:56
@lzmhhh123 lzmhhh123 force-pushed the dev/add_hint_for_access_flash branch from d04052a to 7998b80 Compare August 23, 2019 06:54
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

@lzmhhh123 lzmhhh123 merged commit c23214d into pingcap:master Aug 23, 2019
@lzmhhh123 lzmhhh123 deleted the dev/add_hint_for_access_flash branch August 23, 2019 07:09
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.

7 participants