Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
ddl: batch check the constrains when we add a unique-index. #7132
What have you changed? (mandatory)
Before this PR, we check if the key is duplicate every row, it will be much slower than adding a non-unique index. In this PR, before we create a unique index, we batch check the keys, and skip the keys that already exists.
I built a cluster using ansible on my virtual machine. And use importer to produce a table with 1 million rows. Then I try to add a unique index on it, with this PR and the master branch. I got the result:
master branch costs 7m25s, and this pr costs 1m41s to finish it. This PR has about 77.3% improvement.
This PR needs to cherry-pick to 2.0.
What is the type of the changes? (mandatory)
How has this PR been tested? (mandatory)
Does this PR affect documentation (docs/docs-cn) update? (mandatory)
Does this PR affect tidb-ansible update? (mandatory)
Does this PR need to be added to the release notes? (mandatory)
Refer to a related PR or issue link (optional)
Benchmark result if necessary (optional)
Add a few positive/negative examples (optional)