In MySQL5.1.X, create and delete clustered indexes: 1. Create an empty table with the same structure as the original table, and then create a clustered index. 2. copy the data from the original table to the new table, an exclusive lock will be applied to the original table.
In MySQL5.1.X, create and delete clustered indexes: 1. Create an empty table with the same structure as the original table, and then create a clustered index. 2. copy the data from the original table to the new table, an exclusive lock will be applied to the original table.
3. After copying, delete the original table and rename the new table as the original table.
3. After copying, delete the original table and rename the new table as the original table.
In MySQL 5.5.x, creating and deleting non-clustered indexes does not need to be copied to the entire table,
You only need to update the index page, which is faster than before. However, when creating a clustered index (Primary Key), a website space, or a foreign key, a Hong Kong Space still needs to copy the content of the entire table, because the clustered index stores the primary key and row data together, it is free of Record Filing space, while the secondary index is stored separately, and then a pointer pointing to the primary key.
The following is a comparison of the non-clustered index creation speed:
See the MySQL5.5 manual:
This article is from the "hechun's technical column" blog. Be sure to keep this source