MySQL Variables thread_pool_max_unused_threads 数据库 参数变量解释及正确配置使用
本站中文解释
thread_pool_max_unused_threads是MySQL中线程池参数,用于控制池中未使用线程(unused thread)的最大数量。
这个参数的默认值是Thread_pool_prio_kickup_timer的5倍,所以当Thread_pool_prio_kickup_timer的值大于0时,thread_pool_max_unused_threads的默认值是Thread_pool_prio_kickup_timer乘以5。通常,thread_pool_max_unused_threads设置为0以关闭池中未使用线程的保持。
如果Thread_pool_prio_kickup_timer> 0,可以在MySQL命令行界面上使用如下命令来设置thread_pool_max_unused_threads:
set global thread_pool_max_unused_threads=5;
如果Thread_pool_prio_kickup_timer= 0,可以使用如下命令来设置thread_pool_max_unused_threads:
set global thread_pool_max_unused_threads=0;
官方英文解释
thread_pool_max_unused_threads
Command-Line Format | --thread-pool-max-unused-threads=# |
---|---|
System Variable | thread_pool_max_unused_threads |
Scope | Global |
Dynamic | Yes |
Type | Integer |
Default Value | 0 |
Minimum Value | 0 |
Maximum Value | 4096 |
The maximum permitted number of unused threads in the thread
pool. This variable makes it possible to limit the amount of
memory used by sleeping threads.
A value of 0 (the default) means no limit on the number of
sleeping threads. A value of N
where N
is greater than 0 means 1
consumer thread and N
−1
reserve threads. In this case, if a thread is ready to sleep
but the number of sleeping threads is already at the maximum,
the thread exits rather than going to sleep.
A sleeping thread is either sleeping as a consumer thread or a
reserve thread. The thread pool permits one thread to be the
consumer thread when sleeping. If a thread goes to sleep and
there is no existing consumer thread, it sleeps as a consumer
thread. When a thread must be woken up, a consumer thread is
selected if there is one. A reserve thread is selected only
when there is no consumer thread to wake up.
This variable is available only if the thread pool plugin is
enabled. See Section 5.5.3, “MySQL Enterprise Thread Pool”.