-
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
*: fast path point select #6937
Conversation
fe4c4a8
to
41d35ee
Compare
Skip optimizer and coprocessor for point select.
41d35ee
to
2198b32
Compare
/run-all-tests |
/run-all-tests |
/run-all-tests |
/run-mybatis-test |
/rebuild |
…nt-select Conflicts: plan/plan.go plan/stats.go
…nt-select Conflicts: cmd/explaintest/r/explain_easy.result statistics/selectivity_test.go
@tiancaiamao PTAL |
plan/stats.go
Outdated
@@ -69,10 +69,14 @@ func newSimpleStats(rowCount float64) *statsInfo { | |||
return &statsInfo{count: rowCount} | |||
} | |||
|
|||
func (p *basePhysicalPlan) StatsInfo() *statsInfo { | |||
func (p *basePhysicalPlan) statsInfo() *statsInfo { |
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.
Why do this?
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.
The golint
reports error about returning unexported type.
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.
Since it's unexported now, is this interface still needed?
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.
Most of changes that change handle
to Handle
should be reverted.
plan/rule_partition_processor.go
Outdated
@@ -41,7 +41,7 @@ type partitionProcessor struct{} | |||
func (s *partitionProcessor) optimize(lp LogicalPlan) (LogicalPlan, error) { | |||
// NOTE: partitionProcessor will assume all filter conditions are pushed down to | |||
// DataSource, there will not be a Selection->DataSource case, so the rewrite just | |||
// handle the DataSource node. | |||
// Handle the DataSource node. |
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.
It's not the first word of the sentence.
@winoros PTAL |
executor/point_select.go
Outdated
idxInfo: p.IndexInfo, | ||
idxVals: p.IndexValues, | ||
handle: p.Handle, | ||
startTS: b.getStartTS(), |
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.
Why not use math.MaxUint64
?
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.
The statement may be UPDATE/DELETE or in an explicit transaction.
executor/point_select.go
Outdated
|
||
func (e *PointSelectExecutor) get(key kv.Key) (val []byte, err error) { | ||
txn := e.ctx.Txn() | ||
if txn != nil && txn.Valid() && !txn.IsReadOnly() { |
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.
When will this happen? PointUpdate?
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
expression/integration_test.go
Outdated
@@ -1581,8 +1581,6 @@ func (s *testIntegrationSuite) TestTimeBuiltin(c *C) { | |||
// TODO: MySQL returns "<nil> <nil>". | |||
result.Check(testkit.Rows("0000-00-01 <nil>")) | |||
tk.MustQuery("show warnings").Check(testutil.RowsWithSep("|", "Warning|1292|Incorrect datetime value: '0000-00-00 00:00:00'")) | |||
result = tk.MustQuery("select str_to_date('2018-6-1', '%Y-%m-%d'), str_to_date('2018-6-1', '%Y-%c-%d'), str_to_date('59:20:1', '%s:%i:%k'), str_to_date('59:20:1', '%s:%i:%l')") |
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 wonder why it's removed?
plan/point_select_plan.go
Outdated
|
||
func findPKHandle(tblInfo *model.TableInfo, pairs []nameValuePair) (d types.Datum) { | ||
if !tblInfo.PKIsHandle { | ||
return 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.
d.SetNULL or return something like NULL constant is bettter
This code come with the assumption types.KindInt64 != 0
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.
uninitialized Datum is null is a very intuitive and reasonable assumption.
types/time.go
Outdated
"%Y": yearNumericFourDigits, // Year, numeric, four digits | ||
"%b": abbreviatedMonth, // Abbreviated month name (Jan..Dec) | ||
"%c": monthNumeric, // Month, numeric (0..12) | ||
"%d": dayOfMonthNumericTwoDigits, // Day of the month, numeric (00..31) |
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.
You can probably do this kind of things in another PR
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.
This may be caused by merge conflict.
I think it's better to find a consistent name for it, maybe PointXXX or FastPathXXX? |
Yes, we should keep consistent. |
executor/point_get.go
Outdated
"golang.org/x/net/context" | ||
) | ||
|
||
func (b *executorBuilder) buildPointSelect(p *plan.PointGetPlan) Executor { |
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.
s/buildPointSelect/buildPointGet/
executor/point_get.go
Outdated
} | ||
|
||
func (e *PointGetExecutor) decodeRowValToChunk(rowVal []byte, chk *chunk.Chunk) error { | ||
colIDs := make(map[int64]int) |
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.
Make with capacity.
It would be nice if maybe you could fix the CI, rest looks good to me @coocood |
@tiancaiamao @winoros @zz-jason @jackysp I remove the point-get plan for Update support can be added in future PR. |
/run-all-tests |
/run-all-tests |
/run-mybatis-test |
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
LGTM |
@@ -1483,7 +1485,7 @@ func buildNoRangeTableReader(b *executorBuilder, v *plan.PhysicalTableReader) (* | |||
if containsLimit(dagReq.Executors) { | |||
e.feedback = statistics.NewQueryFeedback(0, nil, 0, ts.Desc) | |||
} else { | |||
e.feedback = statistics.NewQueryFeedback(ts.Table.ID, ts.Hist, ts.StatsInfo().Count(), ts.Desc) | |||
e.feedback = statistics.NewQueryFeedback(ts.Table.ID, ts.Hist, int64(ts.StatsCount()), ts.Desc) |
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.
why make this change?
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.
go lint reports error because it returns an unexported type statsInfo
.
return nil | ||
} | ||
handleDatum := findPKHandle(tbl, pairs) | ||
if handleDatum.Kind() == types.KindInt64 { |
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.
Consider unsign flag?
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.
handle
is always int64.
unsign flag doesn't matter.
What have you changed? (mandatory)
Skip optimizer and coprocessor for point select.
What are the type of the changes (mandatory)?
The currently defined types are listed below, please pick one of the types for this PR by removing the others:
How has this PR been tested (mandatory)?
Sysbench point select.
Refer to a related PR or issue link (optional)
Benchmark result if necessary (optional)
With a single faketikv and single tidb-server on a 24 core linux machine, improve sysbench point select by 60%, from 19000 to 32000
Add a few positive/negative examples (optional)