Before MySQL 5.6Update steps
After MySQL 5.6 Update steps
Summarize ALTER TABLE adding a column will lock it. However, after MySQL version 5.6, the ONLINE DDL function was added, which can greatly shorten the time that the table is unavailable. Notice When adding fields to ALTER TABLE. If the amount of data in the table is very large. Do not set the default value. UPDATE `table_name` SET new_col = [default value] WHERE TRUE This is equivalent to updating 2000w+ data in the same transaction. That is to say, this transaction will lock the entire table and will not be committed until all data records are updated with default values. This time is very long, and because all records in the table are locked, the table will be unavailable for a very long time. The author has experimented with 16 cores, 32G, and the default configuration of Mysql. 5 million data plus one field. Without the default value, the entire DDL update process takes 66 seconds. Moreover, during the entire update process, query, modification, and addition operations of the table are available. There is virtually no impact on the usability of the table. With the default value, the entire DDL update process takes 213 seconds. After testing, it was found that after about 100 seconds, the query, modification, and addition operations of the table would fall into a waiting state. This is the end of this article about whether to lock the table when adding fields in Mysql ALTER TABLE. For more relevant content about adding fields in Mysql ALTER TABLE, please search for previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope you will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Pure CSS to implement iOS style open and close selection box function
>>: How to implement digital paging effect code and steps in CSS
Preface: I reinstalled win10 and organized the fi...
Several common paging methods: 1. Escalator metho...
Table of contents UI Design Echarts example effec...
This article shares the specific code of JS to ac...
Hello everyone! I am Mr. Tony who only talks abou...
1. Embed is illegal The <embed> tag is a pri...
Note: Other machines (IP) cannot connect to the M...
When newbies develop div+css, they need to name t...
This article shares the specific code of js canva...
The importance of data consistency and integrity ...
Operating system: windowns10_x64 Python version: ...
This article shares the installation and configur...
1. Idea It only took 6 seconds to insert 1,000,00...
Preface This article mainly introduces the use an...
1. Overview Users expect the web applications the...