MySQL performance optimization special articles ---3/4

innobuffer and transaction

1. Innodb_buffer_pool_size: Innodb cache, which can be used to cache indexes and also cache actual data;

     The innodb_buffer_pool_size parameter is used to set the size of Innodb's most important Buffer (Innodb_Buffer_Pool), which has the greatest impact on the overall performance of Innodb, and can be set larger as needed;

2, Transaction processing in innodb:

1. Understand the Innodb transaction mechanism:

1. The transaction modifies the data in the buffer;

2. The transaction changes are recorded in the transaction log;

3. Synchronize the data in the transaction log to the database at the right time ;

2. So when the transaction log file is submitted will have a greater impact on system performance. You can modify the transaction log synchronization timing by setting innodb_flush_log_at_trx_commit:

1, innodb_flush_log_at_trx_commit = 0, synchronize the transaction log file every 1 second;

2. Innodb_flush_log_at_trx_commit = 1, the default setting, after each transaction is completed, the transaction log file is synchronized once;

3. Innodb_flush_log_at_trx_commit = 2, after the transaction is completed, write to the transaction log file, wait until the log is overwritten, and then synchronize the data;

Note that 1 has the worst performance, 2 cannot fully guarantee that the data is written to the data file, if there is a downtime, there may be data loss, but the performance is the highest; 1, the performance and security are in the middle;

Guess you like

Origin blog.csdn.net/LB_Captain/article/details/114171970