Skip to content
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

Merged
merged 21 commits into from
Jul 30, 2018
Merged

*: fast path point select #6937

merged 21 commits into from
Jul 30, 2018

Conversation

coocood
Copy link
Member

@coocood coocood commented Jun 29, 2018

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:

  • Improvement (non-breaking change which is an improvement to an existing feature)

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)

@coocood coocood force-pushed the fast-point-select branch 5 times, most recently from fe4c4a8 to 41d35ee Compare July 3, 2018 03:46
Skip optimizer and coprocessor for point select.
@coocood coocood force-pushed the fast-point-select branch from 41d35ee to 2198b32 Compare July 10, 2018 06:56
@coocood coocood changed the title *: fast point select path *: fast path point select Jul 10, 2018
@coocood
Copy link
Member Author

coocood commented Jul 10, 2018

/run-all-tests

@coocood
Copy link
Member Author

coocood commented Jul 11, 2018

/run-all-tests

@coocood
Copy link
Member Author

coocood commented Jul 11, 2018

/run-all-tests

@coocood
Copy link
Member Author

coocood commented Jul 11, 2018

/run-mybatis-test

@coocood
Copy link
Member Author

coocood commented Jul 15, 2018

/rebuild

…nt-select

Conflicts:
	plan/plan.go
	plan/stats.go
…nt-select

Conflicts:
	cmd/explaintest/r/explain_easy.result
	statistics/selectivity_test.go
@coocood
Copy link
Member Author

coocood commented Jul 19, 2018

@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 {
Copy link
Member

Choose a reason for hiding this comment

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

Why do this?

Copy link
Member Author

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.

Copy link
Member

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?

Copy link
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.

Most of changes that change handle to Handle should be reverted.

@@ -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.
Copy link
Member

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.

@coocood
Copy link
Member Author

coocood commented Jul 23, 2018

@winoros PTAL

idxInfo: p.IndexInfo,
idxVals: p.IndexValues,
handle: p.Handle,
startTS: b.getStartTS(),
Copy link
Contributor

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 ?

Copy link
Member Author

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.


func (e *PointSelectExecutor) get(key kv.Key) (val []byte, err error) {
txn := e.ctx.Txn()
if txn != nil && txn.Valid() && !txn.IsReadOnly() {
Copy link
Contributor

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?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes

@@ -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')")
Copy link
Contributor

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?


func findPKHandle(tblInfo *model.TableInfo, pairs []nameValuePair) (d types.Datum) {
if !tblInfo.PKIsHandle {
return d
Copy link
Contributor

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

Copy link
Member Author

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)
Copy link
Contributor

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

Copy link
Member Author

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.

@jackysp
Copy link
Member

jackysp commented Jul 25, 2018

I think it's better to find a consistent name for it, maybe PointXXX or FastPathXXX?
:-)

@ngaut
Copy link
Member

ngaut commented Jul 27, 2018

Yes, we should keep consistent.

@ngaut ngaut closed this Jul 27, 2018
@ngaut ngaut reopened this Jul 27, 2018
"golang.org/x/net/context"
)

func (b *executorBuilder) buildPointSelect(p *plan.PointGetPlan) Executor {
Copy link
Member

Choose a reason for hiding this comment

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

s/buildPointSelect/buildPointGet/

}

func (e *PointGetExecutor) decodeRowValToChunk(rowVal []byte, chk *chunk.Chunk) error {
colIDs := make(map[int64]int)
Copy link
Member

Choose a reason for hiding this comment

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

Make with capacity.

@tiancaiamao
Copy link
Contributor

It would be nice if maybe you could fix the CI, rest looks good to me @coocood

@coocood
Copy link
Member Author

coocood commented Jul 30, 2018

@tiancaiamao @winoros @zz-jason @jackysp

I remove the point-get plan for UPDATE for now, to make the test pass quickly.

Update support can be added in future PR.

@coocood
Copy link
Member Author

coocood commented Jul 30, 2018

/run-all-tests

@coocood
Copy link
Member Author

coocood commented Jul 30, 2018

/run-all-tests

@coocood
Copy link
Member Author

coocood commented Jul 30, 2018

/run-mybatis-test

Copy link
Member

@ngaut ngaut left a comment

Choose a reason for hiding this comment

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

LGTM

@tiancaiamao
Copy link
Contributor

LGTM

@coocood coocood merged commit 343cb84 into pingcap:master Jul 30, 2018
@coocood coocood deleted the fast-point-select branch July 30, 2018 10:13
@@ -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)
Copy link
Member

Choose a reason for hiding this comment

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

why make this change?

Copy link
Member Author

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 {
Copy link
Member

Choose a reason for hiding this comment

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

Consider unsign flag?

Copy link
Member Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants