Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

A brief introduction to Ten parameters for optimizing the performance of MySQL Database

2025-03-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces "A brief introduction of ten parameters for optimizing the performance of MySQL database". In daily operation, I believe many people have doubts about the brief introduction of ten parameters for optimizing the performance of MySQL database. Xiaobian consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubts of "ten parameters for optimizing the performance of MySQL database". Next, please follow the editor to study!

(1) max_connections:

The number of simultaneous customers allowed. Increase this value to increase the number of file descriptors required by d. This number should be increased, otherwise you will often see too many connections errors. The default value is 100, and I'll change it to 1024.

(2) record_buffer:

Each thread that performs a sequential scan allocates a buffer of this size to each table it scans. If you do a lot of sequential scans, you may want to increase this value. The default value is 131072 (128k), which I changed to 16773120 (16m)

(3) key_buffer_size:

The index block is buffered and shared by all threads. Key_buffer_size is the buffer size for index blocks, increasing it to get better-handled indexes (for all reads and multiple overrides) as much as you can afford. If you make it too big, the system will start to change pages and really slow down. The default value is 8388600 (8m), and my mysql host has 2gb memory, so I changed it to 402649088 (400mb).

(4) back_log:

The number of connections required for mysql. This works when the main mysql thread gets a lot of connection requests in a very short period of time, and then the main thread takes some (albeit short) time to check the connection and start a new thread.

The back_log value indicates how many requests can be stored on the stack in a short period of time before mysql temporarily stops answering new requests. Only if you expect to have many connections in a short period of time, you need to increase it, in other words, this value is the size of the listening queue for incoming tcp/ip connections. Your operating system has its own limits on the queue size. Trying to set the limit that back_log is higher than your operating system will not be valid.

When you look at your list of host processes and find a large number of 264084 | unauthenticated user | xxx.xxx.xxx.xxx | connect | null | login | null processes to be connected, you need to increase the value of back_log. The default value is 50, and I'll change it to 500.

(5) interactive_timeout:

The number of seconds the server waits for action on an interactive connection before closing it. An interactive customer is defined as a customer who uses the client_interactive option for mysql_real_connect (). The default value is 28800, and I'll change it to 7200.

(6) sort_buffer:

Each thread that needs to sort allocates a buffer of that size. Increase this value to speed up order by or group by operations. The default value is 2097144 (2m), which I changed to 16777208 (16m).

(7) table_cache:

The number of open tables for all threads. Increasing this value increases the number of file descriptors required by mysqld. Mysql requires 2 file descriptors for each unique open table. The default value is 64, and I'll change it to 512.

(8) thread_cache_size:

The number of threads saved in that can be reused. If so, the new thread is fetched from the cache, and the customer's line is placed in the cache if there is space when the connection is disconnected. If there are many new threads, the value of this variable can be used to improve performance. By comparing the variables of the connections and threads_created states, you can see the effect of this variable. I set it to 80.

(9) search function of mysql

Search with mysql in order to be able to search in Chinese regardless of case

Just specify-- default-character-set=gb2312 when you start mysqld

(10) wait_timeout:

The number of seconds the server waits for action on a connection before shutting it down. The default value is 28800, and I'll change it to 7200.

Note: parameters can be adjusted by modifying the / etc/my.cnf file and restarting mysql. This is a more cautious work, and the above results are just some of my views, which you can further modify according to the hardware of your own host (especially the memory size).

At this point, the study on "A brief introduction to Ten parameters for optimizing the performance of MySQL Database" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report