mysql7.5.23 adjustment innodb_buffer_pool_size

 

Foreword

      My database version is 5.7.23, the recent discovery of more and more slow implementation of SQL, a SQL statement is executed take nearly 30s.

 

 

 

 

 

 

 

 

 

 

    For the reason, query data,  https://www.cnblogs.com/qwangxiao/p/8921196.html one paper wrote:

The cause of slow implementation of SQL:

1. Hardware problem. As the network is slow, insufficient memory, small I / O throughput, disk space is full and so on.

I check memory, disk utilization as follows:

 

 

 

2. There is no index or index fail. (Usually in Internet companies, DBA will lock the table in the middle of the night to re-establish the index again, because when you delete a data, the index tree structure is not complete, so the Internet company's data to do is fake deleted. One is to do data analysis, and second, in order not to destroy the index)

All we are doing is fake delete data, the index also built in.

3. Too much data (sub-library sub-table)

 

 

 Indeed a large amount of data, so we are also selected points table.

 

 

 

4. The server and each tuning parameter (the my.cnf adjustment)

 

Adjust parameters innodb_buffer_pool_size 

  The above three points, check the basic pass, there is only the last point, and the corresponding adjustment of parameters my.cnf, my first thought is innodb_buffer_pool_size, for this parameter https://blog.csdn.net/kk185800961/article/details/ 79378313 / mentioned in the article: a memory size of the cache index and data, this is of course possible, read and write data in memory very quickly, reducing disk reads. When the data is submitted after the checkpoint or to meet conditions of a one-time refresh memory data to disk. However, there are operating system or database memory used by other processes, usually set buffer pool size is 3/4 to 4/5 of the total memory. 

  And proposed: Jiaoyou set: Suppose the system memory = 128 GB, buffer pool size expected 100GB (128GB * 80%)

innodb_buffer_pool_instances = 8 # default values, or logical number of the CPU
innodb_buffer_pool_chunk_size = 128MB # Default
innodb_buffer_pool_size = 100 GB # N * 8 * 128MG = N GB, N is a positive integer exactly. N = 100 is provided so that the total memory buffer pool is 3/4 to 4/5.


  My server is the number of logical CPU 4, the memory is 15G.

 

 

 Current innodb_buffer_pool_instances = 1, innodb_buffer_pool_chunk_size and innodb_buffer_pool_size = 134217728, which is 128M.

 

 

 

 

 

 

 I will be above parameters have increased four times.

  SET GLOBAL innodb_buffer_pool_size=536870912‬;
  SET GLOBAL innodb_buffer_pool_chunk_size =536870912‬;
SELECT
    @@innodb_buffer_pool_instances,
    @@innodb_buffer_pool_chunk_size,
    @@innodb_buffer_pool_size

See SQL execution faster 7s

 

 So I continue to change the configuration:

 

 

 

 

 

 

 

 

 

 

 

 At this speed increase by half. After repeated testing, we found that the following configuration, the fastest, the three parameters of the final configuration (/etc/my.cnf years) are:

innodb_buffer_pool_size = 1280M
innodb_buffer_pool_chunk_size= 1280M
innodb_buffer_pool_instances=1

 

 

 

 

 



Guess you like

Origin www.cnblogs.com/yybrhr/p/11445748.html