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
Table of contents 1. Sample code 2. See the essen...
Today I suddenly thought of reviewing the producti...
Require The div under the body is vertically cent...
Scenario Requirements 1. We can use the script fu...
XML Schema is an XML-based alternative to DTD. XM...
Preface When backing up the database, a full data...
Table of contents Installation Steps Environment ...
A brief analysis of rem First of all, rem is a CS...
This article shares the specific code of Vue to a...
This article uses examples to illustrate the opti...
Preface I have read many similar articles before,...
Table of contents Dockerfile pom.xml Jenkins Conf...
Table of contents Linux netstat command 1. Detail...
Install the nvidia graphics card driver under Ubu...
Operating system: Window10 MySQL version: 8.0.13-...