您的位置:首页 > 数据库 > MySQL

红薯 MySQL 5.5 和 5.6 默认参数值的差异

2013-02-28 10:39 302 查看
作为MySQL5.5和5.6性能比较的一部分,我研究了下两个版本默认参数的差异,为了了解差异内容,我使用如下的SQL语句分别在MySQL5.5和5.6版本进行查询,得出下表(点击图片查看大图)





让我们来看看这些差异的配置中最重要的也是影响最大的部分:

performance_schema在MySQL5.6中默认是开启的,但相关的很多参数相比MySQL5.5却是降低了,例如performance_schema自动调整到445个表和224线程,比MySQL5.5低。尽管默认max_connections只是150,比200还小。

innodb_stats_on_metadata在MySQL5.6默认关闭,使得information_schema的查询速度快很多。

innodb_log_file_size–默认值从5MB提升到50MB,这是一个好的改变,虽然我觉得这个默认数值还可以再大些。对于写负载高的情况下,默认配置的MySQL5.6性能更好。

back_log改动比较小,从50改为80。如果系统每秒处理的连接数很高,还需要继续提高这个配置的值。

open_files_limit由原来的1024改为5000

innodb_auto_extend_increment由8MB改为64MB,可帮助降低碎片。

max_connect_errors从10改为100,可降低潜在的连接堵塞,但还可以更高些。

sort_buffer_size从2M将为256K,这可避免小排序导致的资源浪费,但是对大的排序有负面的影响。

max_allowed_packet从1MB改为4MB让MySQL可处理更大的查询。

join_buffer_size从128K改为256K,我觉得这个改动影响不大。

table_open_cache从400提高到2000,挺好!

innodb_buffer_pool_instances从1改为8,用于优化更高并发的负载。

query_cache_type和query_cache_size.Thebehavioris“nocache”bydefaultstillbutitisachieveddifferentlynow.Thequery_cache_typeisnowoffbydefaultwithdefaultsizeof1MBwhileinMySQL5.5andbeforeitwas“ON”bydefaultwithquerycachesizeof0whichmakesitdisabled.Iwishquery_cache_sizethoughwouldbelargerbydefaultasvalueof1Mistoosmalltobepracticalifsomeonetriestoenableit.

sql_modehasNO_ENGINE_SUBSTITUTIONvaluebydefaultwhichisgoodchangeastryingtocreateInnodbtablebutgettingMyISAMbecauseInnodbwasdisabledforsomereasonwasveryerrorpronegotcha.NotethisisasfarasMySQL5.6goes-STRICT_MODEandothersaferbehaviorsarenotenabledbydefault.

innodb_old_blocks_time设置为1000,很好的改变,默认扫描InnoDB缓冲池大小。

thread_cache_size默认启用,对很多连接和断开连接操作的情况下有帮助。

sync_relay_log_infoandsync_master_info默认值有原来的0改为10000.该改动几乎不会影响负载。

secure_auth默认开启,要求新的密码握手,特别是阻止老的不安全的做法,很好!

innodb_concurrency_ticketshasbeenincreasedfrom500to5000.Ifyou’reusinginnodb_thread_concurrencythiswillreduceoverheadassociatedwithgrabbingandreleasinginnodb_thread_concurrencyslotbutwillincreasepotentialstarvationofqueuedthreadsespeciallyforIOboundworkloads.Mostuserswillnotbeaffectedthoughasinnodb_thread_concurrencyis0bydefaultsothisqueuingfeatureisdisabled.

innodb_purge_threads默认为1,使用专用的后台purge线程,好!

innodb_open_files由300改为2000,好!

innodb_data_file_pathgotasmallchangewithstartingibdata1sizeraisedfrom10Mto12M.I’mnotsurewhatisthepurposeofthischangebutitisunlikelytohaveanypracticalmeaningforusers.Consideringthedefaultinnodb_auto_extend_incrementis64startingwith64Mmighthavemademoresense.

innodb_purge_patch_size从20改为300.

innodb_file_per_table默认启用,这个改变很大,而且很棒。特别是当你的表非常大的时候。

optimizer_switchisthecatchallvariableforalotofoptimizeroptions.Iwonderwhywasnotitimplementedasnumberofdifferentvariableswhichwouldmakemoresenseinmyopinion.MySQL5.6addsalotmoreoptimizerswitcheswhichyoucanplaywith:

01
mysql[localhost]{msandbox}(test)>
select
*
from
var55
where
variable_name=
'OPTIMIZER_SWITCH'
\G
02
***************************1.row***************************
03
VARIABLE_NAME:OPTIMIZER_SWITCH
04
VARIABLE_VALUE:index_merge=
on
,index_merge_union=
on
,index_merge_sort_union=
on
,index_merge_intersection=
on
,engine_condition_pushdown=
on
05
1row
in
set
(0.00sec)
06
07
mysql[localhost]{msandbox}(test)>
select
*
from
var56
where
variable_name=
'OPTIMIZER_SWITCH'
\G
08
***************************1.row***************************
09
VARIABLE_NAME:OPTIMIZER_SWITCH
10
VARIABLE_VALUE:index_merge=
on
,index_merge_union=
on
,index_merge_sort_union=
on
,index_merge_intersection=
on
,engine_condition_pushdown=
on
,index_condition_pushdown=
on
,mrr=
on
,mrr_cost_based=
on
,block_nested_loop=
on
,batched_key_access=
off
,materialization=
on
,semijoin=
on
,loosescan=
on
,firstmatch=
on
,subquery_materialization_cost_based=
on
,use_index_extensions=
on
11
1row
in
set
(0.00sec)
总结:MySQL5.6对默认配置进行了一些微调,这些调整大多数都非常不错。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: