-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
table: use evalBuffer to improve performance of locatePartition #18818
Conversation
Here is a simple Before this fix:
After using optimize:
The performance improvement is very clear in |
Codecov Report
@@ Coverage Diff @@
## master #18818 +/- ##
===========================================
Coverage 79.1417% 79.1417%
===========================================
Files 550 550
Lines 149749 149749
===========================================
Hits 118514 118514
Misses 21689 21689
Partials 9546 9546 |
func (t *partitionedTable) locateRangePartition(ctx sessionctx.Context, pi *model.PartitionInfo, r []types.Datum) (int, error) { | ||
var ret int64 | ||
if col, ok := t.partitionExpr.Expr.(*expression.Column); ok { | ||
ret = r[col.Index].GetInt64() |
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.
Would the column be null?
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 add some test to cover these cases, PTAL @tiancaiamao
// TODO: supports linear hashing | ||
func (t *partitionedTable) locateHashPartition(ctx sessionctx.Context, pi *model.PartitionInfo, r []types.Datum) (int, error) { | ||
ret, isNull, err := t.partitionExpr.Expr.EvalInt(ctx, chunk.MutRowFromDatums(r).ToRow()) | ||
if col, ok := t.partitionExpr.Expr.(*expression.Column); ok { | ||
ret := r[col.Index].GetInt64() |
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.
r[col.Index] is null?
Please add more test to cover the new code. |
311d51a
to
fd0cddc
Compare
LGTM |
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
ae241e8
to
c4e4227
Compare
704a42d
to
7be36cf
Compare
/merge |
Your auto merge job has been accepted, waiting for:
|
/run-all-tests |
faeaecc
to
56733c0
Compare
/run-all-tests |
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
/merge |
/run-all-tests |
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
cherry pick to release-3.0 in PR #19647 |
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
cherry pick to release-4.0 in PR #19649 |
…) (#19647) Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
What problem does this PR solve?
Issue Number: close #16667
Problem Summary:
MutRowFromDatums
is so heavy that causelocatePartition
performance worse than expected. Especially inLOAD DATA
, partition table need nearly twice time than general table.What is changed and how it works?
What's Changed:
partition by hash(col)
orpartition by range(col)
, get integer value directly.evalBuffer
to avoidMutRowFromDatums
repeatly.How it Works:
This two method will avoid using
MutRowFromDatums
many times. improve the write performance of partition table.Related changes
Check List
Tests
Side effects
Release note