Changing thread_cache_size in MySQL

thread_cache_size – responsible for caching client threads after they are disconnected so that they can be reused, for example, when hundreds of connections are made to the server per second, this parameter can greatly improve performance.

You can view the current value like this:

SHOW GLOBAL VARIABLES LIKE 'thread_cache_size';
SHOW VARIABLES LIKE 'thread_cache_size';

To determine whether you need to change the value of thread_cache_size, you need to look at the statistics:

SHOW GLOBAL STATUS LIKE 'Threads_%';

If the Threads_created value is much larger than Threads_cached, then you can increase the thread_cache_size value, for example:

SET GLOBAL thread_cache_size = 32;

We will also indicate in the MySQL server configuration file so that the value is not reset after a restart:

[mysqld]
thread_cache_size=32

See my other articles about MySQL

Leave a comment

Leave a Reply