When a company developer executes an insert statement in a test environment, it takes more than 10 seconds to execute successfully. We checked the test environment database performance, data volume, deadlock and other information and found no anomalies. Finally, this problem was solved by modifying the log writing method. 1. Modification MethodModify the /etc/my.cnf file and change innodb_flush_log_at_trx_commit = 1 to 0. However, this will incur the risk of losing data that is not stored in the database within 1 second after the database crashes. The MySQL documentation describes this parameter as follows:
2. Parameter Description
3. NotesWhen set to 0, this mode is the fastest, but less secure. A crash of the mysqld process will result in the loss of all transaction data in the last second. When set to 1, this mode is the safest, but also the slowest. In the event of a mysqld service crash or a server host crash, the binary log may lose at most one statement or one transaction. When set to 2, this mode is faster and safer than 0. All transaction data in the last second may be lost only if the operating system crashes or the system loses power. The two parameters innodb_flush_log_at_trx_commit and sync_binlog are key parameters for controlling MySQL disk write strategy and data security. When both parameters are set to 1, the write performance is the worst. The recommended practice is innodb_flush_log_at_trx_commit=2, sync_binlog=500 or 1000. This is the end of this article about how to solve the problem of MySQL deleting and inserting data very slowly. For more related content about MySQL deleting and inserting data very slowly, 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:
|
>>: Analysis of the reasons why Vue3 uses Proxy to implement data monitoring
MySQL supports nested transactions, but not many ...
Operating system: Win7 64-bit Ultimate Edition My...
Border Style The border-style property specifies ...
Table of contents 1. Check the current status of ...
Prerequisite: Save the .frm and .ibd files that n...
Table of contents Preface 1. Rendering 2. Code 3....
Preface The master-slave replication relationship...
The equal-width layout described in this article ...
Table of contents 1. Overview 1.1 What is strict ...
Hello everyone, I am Liang Xu. When using Linux, ...
Add the following code to the CSS style of the el...
Placing a search box in the top menu bar is a com...
Table of contents Steps to create TCP in Linux Se...
01. Command Overview The seq command is used to g...
Table of contents Overview 1. Compositon API 1. W...