Comparison of index creation speed between mysql5.1 and mysql5.5

Source: Internet
Author: User

In MySQL 5.1.x, the process of creating and deleting clustered indexes is as follows:

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. Other session dml operations will be blocked to ensure data consistency;

3. After copying, delete the original table and rename the new table as the original table.

The process of creating and deleting non-clustered indexes:

1. Create an empty table with the same structure as the original table, and then create a non-clustered index;

2. copy the data from the original table to the new table. A shared lock will be applied to the original table. Other sessions cannot be updated, but data can be queried to ensure data consistency;

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 or a foreign key, you still need to copy the content of the entire table, because the clustered index stores the primary key and row data together, the secondary index is stored separately, and a pointer points to the primary key.

The following is a comparison of the non-clustered index creation speed:

650) this. width = 650; "border =" 0 "src =" http://www.bkjia.com/uploads/allimg/131229/1929226008-0.jpg "alt =" "/>

650) this. width = 650; "border =" 0 "src =" http://www.bkjia.com/uploads/allimg/131229/1929225111-1.jpg "alt =" "/>

See the MySQL5.5 manual:

650) this. width = 650; "border =" 0 "src =" http://www.bkjia.com/uploads/allimg/131229/1929224547-2.jpg "alt =" "/>

650) this. width = 650; "border =" 0 "src =" http://www.bkjia.com/uploads/allimg/131229/1929226062-3.jpg "alt =" "/>

 

This article is from the "hechun's technical column" blog, please be sure to keep this source http://hcymysql.blog.51cto.com/5223301/986271

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.