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

Optimize adding index by remove unnecessary locking #29793

Closed
wjhuang2016 opened this issue Nov 15, 2021 · 0 comments · Fixed by #29772
Closed

Optimize adding index by remove unnecessary locking #29793

wjhuang2016 opened this issue Nov 15, 2021 · 0 comments · Fixed by #29772
Labels
type/enhancement The issue or PR belongs to an enhancement.

Comments

@wjhuang2016
Copy link
Member

Enhancement

tidb/ddl/index.go

Lines 1332 to 1341 in 9c683d3

// Lock the row key to notify us that someone delete or update the row,
// then we should not backfill the index of it, otherwise the adding index is redundant.
err := txn.LockKeys(context.Background(), new(kv.LockCtx), idxRecord.key)
if err != nil {
return errors.Trace(err)
}
// Create the index.
handle, err := w.index.Create(w.sessCtx, txn, idxRecord.vals, idxRecord.handle, idxRecord.rsData)
if err != nil {

We don't need to lock the key when adding an index. And it can cause hot-point.

@wjhuang2016 wjhuang2016 added the type/enhancement The issue or PR belongs to an enhancement. label Nov 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/enhancement The issue or PR belongs to an enhancement.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant