mysql 优化日记
my.ini配置建议:
table_cache=1024
物理内存越大,设置就越大.默认为2402,调到512-1024最佳
innodb_additional_mem_pool_size=4M
默认为2M
innodb_flush_log_at_trx_commit=1
(设置为0就是等到innodb_log_buffer_size列队满后再统一储存,默认为1)
innodb_log_buffer_size=2M
默认为1M
innodb_thread_concurrency=8
你的服务器CPU有几个就设置为几,建议用默认一般为8
key_buffer_size=256M
默认为218 调到128最佳
tmp_table_size=64M
默认为16M 调到64-256最挂
read_buffer_size=4M
默认为64K
read_rnd_buffer_size=16M
默认为256K
sort_buffer_size=32M
默认为256K
max_connections=1024
默认为1210
thread_cache_size=120
默认为60
query_cache_size=32M
———————————
以下是另一个的my.ini配置建议:
port=3306
default-character-set=latin1
default-storage-engine=INNODB
sql-mode=”STRICT_TRANS_TABLES,NO_AUTO_Create_USER,NO_ENGINE_SUBSTITUTION”
max_connections=120
query_cache_size=32M
#缓存数据表数量,设置这个参数可以参见系统状态中的 open_tables(表示当前打开的数据表总数) 和 opened_tables(表示所有打开的数据表总数)
table_cache=256
#临时表的大小
tmp_table_size=12M
#缓存可重用的线程数
thread_cache_size = 64
myisam_max_sort_file_size=100G
myisam_max_extra_sort_file_size=100G
myisam_sort_buffer_size=64M
#这对MyISAM表来说非常重要。如果只是使用MyISAM表,可以把它设置为可用内存的 30-40%。合理的值取决于索引大小、数据量以及负载 – #记住,MyISAM表会使用操作系统的缓存来缓存数据,因此需要留出部分内存给它们,很多情况下数据比索引大多了。
key_buffer_size=128M
read_buffer_size=1M
read_rnd_buffer_size=512K
sort_buffer_size=1M
#这对innodb表来说非常重要
innodb_buffer_pool_size = 256M
#这取决于你需要的回复速度.128M这个数值是适当的恢复时间和良好性能之间的一个好的平衡.
innodb_log_file_size = 128M
#大多数情况4M足够,除非正将很大的blob数据导入到Innodb中可以增加一点.
innodb_log_buffer_size=4M
#这个值取决于你的程序,可能高或者低.8是代表起始值.
innodb_thread_concurrency=8
innodb_additional_mem_pool_size=100M
#如果你不是很关心ACID,可以容许在系统完全crash的情况下丢失最后一两秒的事务,那么可以设置这个值.它可以极大的提高”短”的写事务的效率.
innodb_flush_log_at_trx_commit=2
注意:
很多情况需要具体情况具体分析
1>如果Key_reads太大,则应该把my.cnf中Key_buffer_size变大,保持Key_reads/Key_read_requests至少1/100以上,越小越好。
2>如果Qcache_lowmem_prunes很大,就要增加Query_cache_size的值。
what matters is that you trust yourself as God has in you and try to be who you are ..then this lifetime can be Heaven…
I just watched this, and thought it was really beautiful.
My dear,I love your comment and wisdom
LOL!! Thanks for the laugh!
….yip, keep it simple…. hehehe….
gratitude makes the world go around… thanks for the story
you are an Archetypal figure in our lives ,a masculine image of love and goodness and truth telling,and keeper of our dreams
Such true words.Have a wonderful week.
hehehe You are definitely right!
….interesting….