当前位置:网站首页>MySQL configuration improves data insertion efficiency

MySQL configuration improves data insertion efficiency

2022-06-26 13:45:00 It's strange that the eyes are full of human fireworks

innodb_buffer_pool_size

innodb_buffer_pool_size The default value is 32M, It can be set to 128M.

This parameter indicates mysql Of Innodb A piece of storage engine to optimize query performance Memory buffer

show global VARIABLES like 'innodb_buffer_pool_size'

set global innodb_buffer_pool_size=1024*1024*128;

innodb_flush_log_at_trx_commit

innodb_flush_log_at_trx_commit The default value is 1; Set to 0, Can increase write speed .

The value is 0: Increase write speed , But the security is poor ,mysql Server downtime may cause data loss .

The value is 1: Every time a transaction is committed or an instruction other than a transaction needs to write the log to the hard disk , This process takes a long time ;

show global variables like '%innodb_flush_log_at_trx_commit%'

set global innodb_flush_log_at_trx_commit=0;

innodb_autoextend_increment

innodb_autoextend_increment The default value is 8M, It can be set to 128M

This configuration item is mainly used when tablespace When the space is full , need MySQL How much space does the system need to expand automatically , Every time tablespace Expansion will make each SQL In a waiting state . Add automatic expansion Size Can reduce the tablespace Number of automatic extensions .

show global variables like '%innodb_autoextend_increment%'

set global innodb_autoextend_increment = 128;

innodb_log_buffer_size

innodb_log_buffer_size The default value is 1M, It can be set to 64M

This configuration item is used to set innodb Database engine write log cache ; Increasing this cache segment can reduce the number of times the database writes data files .

show global variables like '%innodb_log_buffer_size%'

set global innodb_log_buffer_size = 1024*1024*64;

innodb_log_file_size

innodb_log_file_size  The default value is 48M, It can be set to 128M


show global variables like '%innodb_log_file_size%'

set global innodb_log_file_size = 1024*1024*128;

innodb_write_io_threads & innodb_read_io_threads 

innodb_write_io_threads & innodb_read_io_threads  The default value is 4, The range of allowed values is 1~64, It is recommended to modify according to the number of server cores ,8 The core is set to 8.

show global variables like '%innodb_write_io_threads%'

set global innodb_write_io_threads = 8;


show global variables like '%innodb_read_io_threads%'

set global innodb_read_io_threads = 8;

innodb_io_capacity & innodb_io_capacity_max

innodb_io_capacity & innodb_io_capacity_max The default is 200,2000, Can be adjusted to 2000,10000.

show global variables like 'innodb_io_capacity%'

set global innodb_io_capacity = 2000;
set global innodb_io_capacity_max = 10000;

原网站

版权声明
本文为[It's strange that the eyes are full of human fireworks]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/177/202206261252398257.html