MySQL Variables thread_cache_size 数据库 参数变量解释及正确配置使用

本站中文解释

thread_cache_size参数用来设置MySQL服务器将根据需要缓存每个线程的活动状态的线程数目。它允许预先指定需要缓存的线程数,以减少系统资源的消耗。

如果你想调整thread_cache_size参数,可以在MySQL命令行界面中执行以下语句,来设置thread_cache_size参数:

SET GLOBAL thread_cache_size = ;

官方英文解释

thread_cache_size

Command-Line Format --thread-cache-size=#
System Variable thread_cache_size
Scope Global
Dynamic Yes
Type Integer
Default Value -1 (signifies autosizing; do not assign this literal value)
Minimum Value 0
Maximum Value 16384

How many threads the server should cache for reuse. When a
client disconnects, the client’s threads are put in the cache
if there are fewer than
thread_cache_size threads
there. Requests for threads are satisfied by reusing threads
taken from the cache if possible, and only when the cache is
empty is a new thread created. This variable can be increased
to improve performance if you have a lot of new connections.
Normally, this does not provide a notable performance
improvement if you have a good thread implementation. However,
if your server sees hundreds of connections per second you
should normally set
thread_cache_size high enough
so that most new connections use cached threads. By examining
the difference between the
Connections and
Threads_created status
variables, you can see how efficient the thread cache is. For
details, see Section 5.1.9, “Server Status Variables”.

The default value is based on the following formula, capped to
a limit of 100:

8 + (max_connections / 100)

This variable has no effect for the embedded server
(libmysqld) and as of MySQL 5.7.2 is no
longer visible within the embedded server.


数据运维技术 » MySQL Variables thread_cache_size 数据库 参数变量解释及正确配置使用