-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
server: prefetch point-get keys for multi-statement queries. #18155
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
continue | ||
} | ||
// Only support Update for now. | ||
// TODO: support other point plans. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we could support select/delete. It won't be very complex.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm trying to make the change as minimum as possible to make the review work easier.
server/conn.go
Outdated
return nil, nil | ||
} | ||
vars := cc.ctx.GetSessionVars() | ||
if vars.TxnCtx.IsPessimistic && vars.TxnCtx.Isolation == ast.ReadCommitted { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe it has a limited effect when IsPessimistic == true && vars.TxnCtx.Isolation == RR
? because it's still need lock per stmt(and lock request also can prefetch cache), but it's great for multi-stmt in side optimistic txn :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I should make it skip pessimistic transactions.
server/conn_test.go
Outdated
query := "update prefetch set c = c + 1 where a = 1 and b = 1;" + | ||
"update prefetch set c = c + 1 where a = 2 and b = 2;" + | ||
"update prefetch set c = c + 1 where a = 3 and b = 3;" | ||
err = cc.handleQuery(ctx, query) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will you add a union scan case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Codecov Report
@@ Coverage Diff @@
## master #18155 +/- ##
===========================================
Coverage 79.6358% 79.6358%
===========================================
Files 526 526
Lines 144425 144425
===========================================
Hits 115014 115014
Misses 20158 20158
Partials 9253 9253 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
PTAL @tiancaiamao
LGTM |
/merge |
/run-all-tests |
@coocood merge failed. |
/run-all-tests |
What problem does this PR solve?
Statements in a multi-statement query are executed one by one currently.
If there are many point plan statements, we can prefetch the point keys, cache them in the transaction snapshot cache. reduce RPC cost and latency.
What is changed and how it works?
Proposal: xxx
What's Changed:
How it works:
Check List
Tests
Release note