How to Create an Index on a Large MySQL Production Table Without Table Locking
Problem Background:
Creating an index on a large MySQL table can be a daunting task, especially in a production environment where uninterrupted access is crucial. Traditional CREATE INDEX statements can result in a complete table lock, blocking all concurrent operations.
MySQL Version Considerations:
Circular Masters Approach:
For MySQL versions prior to 5.6, one effective approach is the circular masters technique:
Percona's pt-online-schema-change Tool:
This tool automates the circular masters approach by:
AWS RDS Considerations:
For MySQL databases hosted on Amazon's RDS, the "Read Replica Promotion" feature can be used to facilitate schema changes without table locking. This involves making changes on a read-only slave and then promoting it to become the new master.
Alternative Techniques:
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3