-
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
*: fix insert on duplicate
and replace into
with global index
#53717
Conversation
Skipping CI for Draft Pull Request. |
Hi @Defined2014. Thanks for your PR. PRs from untrusted users cannot be marked as trusted with I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #53717 +/- ##
================================================
+ Coverage 72.5762% 74.6736% +2.0973%
================================================
Files 1506 1506
Lines 430947 436505 +5558
================================================
+ Hits 312765 325954 +13189
+ Misses 98878 90531 -8347
- Partials 19304 20020 +716
Flags with carried forward coverage won't be shown. Click here to find out more.
|
if len(value) <= MaxOldEncodeValueLen { | ||
return decodeIntHandleInIndexValue(value), nil | ||
} |
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.
Could we remove these codes that look like they will be processed on line988?
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 speeds up the function for simplest int handles(like _tidb_rowid
).
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 performance difference is 9ns/op
compare 15ns/op
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.
Got it.
insert on duplicate
with global indexinsert on duplicate
and replace into
with global index
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
} else { | ||
e.batchKeys = append(e.batchKeys, tablecodec.EncodeRecordKey(e.table.RecordPrefix(), h)) | ||
} | ||
e.batchKeys = append(e.batchKeys, tablecodec.EncodeRecordKey(e.table.RecordPrefix(), h)) |
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.
(Note for future reference)
Will this work with partitions? Is e.table the partition if non-global index, and the logical table if global index?
=> EncodeRecordKey now adds the proper PhysicalTableID (partition id) if partitioned handle.
@@ -1373,7 +1373,11 @@ func (e *InsertValues) removeRow( | |||
return true, nil | |||
} | |||
|
|||
err = r.t.RemoveRecord(e.Ctx().GetTableCtx(), handle, oldRow) | |||
if ph, ok := handle.(kv.PartitionHandle); ok { | |||
err = e.Table.(table.PartitionedTable).GetPartition(ph.PartitionID).RemoveRecord(e.Ctx().GetTableCtx(), ph.Handle, oldRow) |
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.
Also Note for future reference.
We could fix it by handle partition handle in func (c *index) GenIndexKey
, but since the phyTblID
is already included in the index struct, so it is better to add it at the entry of removeRecord
.
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
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: mjonss, zimulala The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
What problem does this PR solve?
Issue Number: close #53711, close #53750
Problem Summary:
insert on duplicate
, we always use the tableID of current value to found the old row. But the partition id between new and old values are different for global index.DecodeHandleInUniqueIndexValue
andDecodeHandleInIndexValue
are similar, so I decided to remove one.What changed and how does it work?
Check List
Tests
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.