我该如何减少这个数字?我有一台四核机器。我是否需要编辑thread_pool_size,通过减少它们是否可以获得更好的性能?
如果查询过多或者发生其他事情,是否会阻塞机器?
[mysqld]
default-storage-engine=MyISAM
local-infile=0
symbolic-links=0
max_connections = 500
max_user_connections = 25
key_buffer = 64M
myisam_sort_buffer_size = 32M
join_buffer_size = 2M
read_buffer_size = 2M
sort_buffer_size = 2M
read_rnd_buffer_size = 2M
table_cache = 1024
thread_cache_size = 16K
wait_timeout = 20
connect_timeout = 10
tmp_table_size = 128M
max_heap_table_size = 128M
max_allowed_packet = 160M
max_connect_errors = 10
query_cache_limit = 1M
query_cache_size = 16M
query_cache_type = 1
low_priority_updates=1
concurrent_insert=ALWAYS
[mysqld_safe]
open_files_limit = 8192
[mysqldump]
max_allowed_packet = 16M
[myisamchk]
key_buffer = 64M
sort_buffer = 64M
read_buffer = 16M
write_buffer = 16M
答案1
似乎您的索引已损坏,甚至可能没有索引的“慢速”查询。
请记住,max_connections
盲目增加是非常危险的。每个线程都会占用大量内存进行缓冲,并且很可能耗尽 RAM,导致页面调度过重,速度反而会减慢。
开启慢查询日志记录:
SET @@global.log_slow_queries = 1;
SET @@global.log_queries_not_using_indexes = 1;
并检查具有高值的行Rows_examined: