Mysql 优化建议

Posted 君子以自强不息

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Mysql 优化建议相关的知识,希望对你有一定的参考价值。

 

1、硬件层相关优化
1.1、CPU相关

在服务器的Bios设置中,可调整下面的几个配置,目的是发挥CPU最大性能,或者避免经典的NUMA问题:

1、选择Performance Per Watt Optimized(DAPC)模式,发挥CPU最大性能,跑DB这种通常需要高运算量的服务就不要考虑节电了;
2、关闭C1E和C States等选项,目的也是为了提升CPU效率
3、Memory Frequency(内存频率)选择Maximum Performance(最佳性能); 4、内存设置菜单中,启用Node Interleaving,避免NUMA问题;
1.2、磁盘I/O相关

下面几个是按照IOPS性能提升的幅度排序,对于磁盘I/O可优化的一些措施:

1、使用SSD或者PCIe SSD设备,至少获得数百倍甚至万倍的IOPS提升;
2、购置阵列卡同时配备CACHE及BBU模块,可明显提升IOPS(主要是指机械盘,SSD或PCIe SSD除外。同时需要定期检查CACHE及BBU模块的健康状况,确保意外时不至于丢失数据);

3、有阵列卡时,设置阵列写策略为WB,甚至FORCE WB(若有双电保护,或对数据安全性要求不是特别高的话),严禁使用WT策略。并且闭阵列预读策略,基本上是鸡肋,用处不大;

4、尽可能选用RAID-10,而非RAID-5;

5、使用机械盘的话,尽可能选择高转速的,例如选用15KRPM,而不是7.2KRPM的盘,不差几个钱的;
2、系统层相关优化
2.1、文件系统层优化

在文件系统层,下面几个措施可明显提升IOPS性能:

1、使用deadline/noop这两种I/O调度器,千万别用cfq(它不适合跑DB类服务);
2、使用xfs文件系统,千万别用ext3;ext4勉强可用,但业务量很大的话,则一定要用xfs;
3、文件系统mount参数中增加:noatime, nodiratime, nobarrier几个选项(nobarrier是xfs文件系统特有的);
2.2、其他内核参数优化

针对关键内核参数设定合适的值,目的是为了减少swap的倾向,并且让内存和磁盘I/O不会出现大幅波动,导致瞬间波峰负载:

1、将vm.swappiness设置为5-10左右即可,甚至设置为0(RHEL 7以上则慎重设置为0,除非你允许OOM kill发生),以降低使用SWAP的机会;
2、将vm.dirty_background_ratio设置为5-10,将vm.dirty_ratio设置为它的两倍左右,以确保能持续将脏数据刷新到磁盘,避免瞬间I/O写,产生严重等待(和mysql中的innodb_max_dirty_pages_pct类似);
3、将net.ipv4.tcp_tw_recycle、net.ipv4.tcp_tw_reuse都设置为1,减少TIME_WAIT,提高TCP效率;
4、至于网传的read_ahead_kb、nr_requests这两个参数,我经过测试后,发现对读写混合为主的OLTP环境影响并不大(应该是对读敏感的场景更有效果),不过没准是我测试方法有问题,可自行斟酌是否调整
3、MySQL层相关优化
3.1、关于版本选择

官方版本我们称为ORACLE MySQL,这个没什么好说的,相信绝大多数人会选择它。建议选择Percona分支版本,它是一个相对比较成熟的、优秀的MySQL分支版本,在性能提升、可靠性、管理型方面做了不少改善。它和官方ORACLE MySQL版本基本完全兼容,并且性能大约有20%以上的提升,因此我优先推荐它,

另一个重要的分支版本是MariaDB,说MariaDB是分支版本其实已经不太合适了,因为它的目标是取代ORACLE MySQL。它主要在原来的MySQL Server层做了大量的源码级改进,也是一个非常可靠的、优秀的分支版本。但也由此产生了以GTID为代表的和官方版本无法兼容的新特性(MySQL 5.7开始,也支持GTID模式在线动态开启或关闭了),也考虑到绝大多数人还是会跟着官方版本走,因此没优先推荐MariaDB

3.2、关于最重要的参数选项调整建议建议

调整下面几个关键参数以获得较好的性能:

1、选择Percona或MariaDB版本的话,强烈建议启用thread pool特性,可使得在高并发的情况下,性能不会发生大幅下降。此外,还有extra_port功能,非常实用, 关键时刻能救命的。还有另外一个重要特色是 QUERY_RESPONSE_TIME 功能,也能使我们对整体的SQL响应时间分布有直观感受;

2、设置default-storage-engine=InnoDB,也就是默认采用InnoDB引擎,强烈建议不要再使用MyISAM引擎了,InnoDB引擎绝对可以满足99%以上的业务场景;

3、调整innodb_buffer_pool_size大小,如果是单实例且绝大多数是InnoDB引擎表的话,可考虑设置为物理内存的50% ~ 70%左右;

4、根据实际需要设置innodb_flush_log_at_trx_commit、sync_binlog的值。如果要求数据不能丢失,那么两个都设为1。如果允许丢失一点数据,则可分别设为2和10。而如果完全不用care数据是否丢失的话(例如在slave上,反正大不了重做一次),则可都设为0。这三种设置值导致数据库的性能受到影响程度分别是:高、中、低,也就是第一个会另数据库最慢,最后一个则相反;

5、设置innodb_file_per_table = 1,使用独立表空间,我实在是想不出来用共享表空间有什么好处了;

6、设置innodb_data_file_path = ibdata1:1G:autoextend,千万不要用默认的10M,否则在有高并发事务时,会受到不小的影响;

7、设置innodb_log_file_size=256M,设置innodb_log_files_in_group=2,基本可满足90%以上的场景;

8、设置long_query_time = 1,而在5.5版本以上,已经可以设置为小于1了,建议设置为0.05(50毫秒),记录那些执行较慢的SQL,用于后续的分析排查;

9、根据业务实际需要,适当调整max_connection(最大连接数)、max_connection_error(最大错误数,建议设置为10万以上,而open_files_limit、innodb_open_files、table_open_cache、table_definition_cache这几个参数则可设为约10倍于max_connection的大小;

10、常见的误区是把tmp_table_size和max_heap_table_size设置的比较大,曾经见过设置为1G的,这2个选项是每个连接会话都会分配的,因此不要设置过大,否则容易导致OOM发生;其他的一些连接会话级选项例如:sort_buffer_size、join_buffer_size、read_buffer_size、read_rnd_buffer_size等,也需要注意不能设置过大;

11、由于已经建议不再使用MyISAM引擎了,因此可以把key_buffer_size设置为32M左右,并且强烈建议关闭query cache功能;
3.3、关于Schema设计规范及SQL使用建议

下面列举了几个常见有助于提升MySQL效率的Schema设计规范及SQL使用建议:
1

、所有的InnoDB表都设计一个无业务用途的自增列做主键,对于绝大多数场景都是如此,真正纯只读用InnoDB表的并不多,真如此的话还不如用TokuDB来得划算;

2、字段长度满足需求前提下,尽可能选择长度小的。此外,字段属性尽量都加上NOT NULL约束,可一定程度提高性能;

3、尽可能不使用TEXT/BLOB类型,确实需要的话,建议拆分到子表中,不要和主表放在一起,避免SELECT * 的时候读性能太差。

4、读取数据时,只选取所需要的列,不要每次都SELECT *,避免产生严重的随机读问题,尤其是读到一些TEXT/BLOB列;

5、对一个VARCHAR(N)列创建索引时,通常取其50%(甚至更小)左右长度创建前缀索引就足以满足80%以上的查询需求了,没必要创建整列的全长度索引;

6、通常情况下,子查询的性能比较差,建议改造成JOIN写法;

7、多表联接查询时,关联字段类型尽量一致,并且都要有索引;

8、多表连接查询时,把结果集小的表(注意,这里是指过滤后的结果集,不一定是全表数据量小的)作为驱动表;

9、多表联接并且有排序时,排序字段必须是驱动表里的,否则排序列无法用到索引;

10、多用复合索引,少用多个独立索引,尤其是一些基数(Cardinality)太小(比如说,该列的唯一值总数少于255)的列就不要创建独立索引了;

11、类似分页功能的SQL,建议先用主键关联,然后返回结果集,效率会高很多;
3.4、其他建议

关于MySQL的管理维护的其他建议有:

1、通常地,单表物理大小不超过10GB,单表行数不超过1亿条,行平均长度不超过8KB,如果机器性能足够,这些数据量MySQL是完全能处理的过来的,不用担心性能问题,这么建议主要是考虑ONLINE DDL的代价较高;

2、不用太担心mysqld进程占用太多内存,只要不发生OOM kill和用到大量的SWAP都还好;

3、在以往,单机上跑多实例的目的是能最大化利用计算资源,如果单实例已经能耗尽大部分计算资源的话,就没必要再跑多实例了;

4、定期使用pt-duplicate-key-checker检查并删除重复的索引。定期使用pt-index-usage工具检查并删除使用频率很低的索引;

5、定期采集slow query log,用pt-query-digest工具进行分析,可结合Anemometer系统进行slow query管理以便分析slow query并进行后续优化工作;

6、可使用pt-kill杀掉超长时间的SQL请求,Percona版本中有个选项 innodb_kill_idle_transaction 也可实现该功能;

7、使用pt-online-schema-change来完成大表的ONLINE DDL需求;

8、定期使用pt-table-checksum、pt-table-sync来检查并修复mysql主从复制的数据差异;`
%0A%23%23%23%23%23%201%E3%80%81%E7%A1%AC%E4%BB%B6%E5%B1%82%E7%9B%B8%E5%85%B3%E4%BC%98%E5%8C%96%0A%23%23%23%23%23%23%20%201.1%E3%80%81CPU%E7%9B%B8%E5%85%B3%0A%E5%9C%A8%E6%9C%8D%E5%8A%A1%E5%99%A8%E7%9A%84BIOS%E8%AE%BE%E7%BD%AE%E4%B8%AD%EF%BC%8C%E5%8F%AF%E8%B0%83%E6%95%B4%E4%B8%8B%E9%9D%A2%E7%9A%84%E5%87%A0%E4%B8%AA%E9%85%8D%E7%BD%AE%EF%BC%8C%E7%9B%AE%E7%9A%84%E6%98%AF%E5%8F%91%E6%8C%A5CPU%E6%9C%80%E5%A4%A7%E6%80%A7%E8%83%BD%EF%BC%8C%E6%88%96%E8%80%85%E9%81%BF%E5%85%8D%E7%BB%8F%E5%85%B8%E7%9A%84NUMA%E9%97%AE%E9%A2%98%EF%BC%9A%0A%60%60%60%0A1%E3%80%81%E9%80%89%E6%8B%A9Performance%20Per%20Watt%20Optimized(DAPC)%E6%A8%A1%E5%BC%8F%EF%BC%8C%E5%8F%91%E6%8C%A5CPU%E6%9C%80%E5%A4%A7%E6%80%A7%E8%83%BD%EF%BC%8C%E8%B7%91DB%E8%BF%99%E7%A7%8D%E9%80%9A%E5%B8%B8%E9%9C%80%E8%A6%81%E9%AB%98%E8%BF%90%E7%AE%97%E9%87%8F%E7%9A%84%E6%9C%8D%E5%8A%A1%E5%B0%B1%E4%B8%8D%E8%A6%81%E8%80%83%E8%99%91%E8%8A%82%E7%94%B5%E4%BA%86%EF%BC%9B%0A2%E3%80%81%E5%85%B3%E9%97%ADC1E%E5%92%8CC%20States%E7%AD%89%E9%80%89%E9%A1%B9%EF%BC%8C%E7%9B%AE%E7%9A%84%E4%B9%9F%E6%98%AF%E4%B8%BA%E4%BA%86%E6%8F%90%E5%8D%87CPU%E6%95%88%E7%8E%873%E3%80%81Memory%20Frequency%EF%BC%88%E5%86%85%E5%AD%98%E9%A2%91%E7%8E%87%EF%BC%89%E9%80%89%E6%8B%A9Maximum%20Performance%EF%BC%88%E6%9C%80%E4%BD%B3%E6%80%A7%E8%83%BD%EF%BC%89%EF%BC%9B%0A4%E3%80%81%E5%86%85%E5%AD%98%E8%AE%BE%E7%BD%AE%E8%8F%9C%E5%8D%95%E4%B8%AD%EF%BC%8C%E5%90%AF%E7%94%A8Node%20Interleaving%EF%BC%8C%E9%81%BF%E5%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6%81%E7%94%A8xfs%EF%BC%9B%0A3%E3%80%81%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9Fmount%E5%8F%82%E6%95%B0%E4%B8%AD%E5%A2%9E%E5%8A%A0%EF%BC%9Anoatime%2C%20nodiratime%2C%20nobarrier%E5%87%A0%E4%B8%AA%E9%80%89%E9%A1%B9%EF%BC%88nobarrier%E6%98%AFxfs%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F%E7%89%B9%E6%9C%89%E7%9A%84%EF%BC%89%EF%BC%9B%0A%60%60%60%0A%23%23%23%23%23%23%202.2%E3%80%81%E5%85%B6%E4%BB%96%E5%86%85%E6%A0%B8%E5%8F%82%E6%95%B0%E4%BC%98%E5%8C%96%0A%E9%92%88%E5%AF%B9%E5%85%B3%E9%94%AE%E5%86%85%E6%A0%B8%E5%8F%82%E6%95%B0%E8%AE%BE%E5%AE%9A%E5%90%88%E9%80%82%E7%9A%84%E5%80%BC%EF%BC%8C%E7%9B%AE%E7%9A%84%E6%98%AF%E4%B8%BA%E4%BA%86%E5%87%8F%E5%B0%91swap%E7%9A%84%E5%80%BE%E5%90%91%EF%BC%8C%E5%B9%B6%E4%B8%94%E8%AE%A9%E5%86%85%E5%AD%98%E5%92%8C%E7%A3%81%E7%9B%98I%2FO%E4%B8%8D%E4%BC%9A%E5%87%BA%E7%8E%B0%E5%A4%A7%E5%B9%85%E6%B3%A2%E5%8A%A8%EF%BC%8C%E5%AF%BC%E8%87%B4%E7%9E%AC%E9%97%B4%E6%B3%A2%E5%B3%B0%E8%B4%9F%E8%BD%BD%EF%BC%9A%0A%60%60%60%0A1%E3%80%81%E5%B0%86vm.swappiness%E8%AE%BE%E7%BD%AE%E4%B8%BA5-10%E5%B7%A6%E5%8F%B3%E5%8D%B3%E5%8F%AF%EF%BC%8C%E7%94%9A%E8%87%B3%E8%AE%BE%E7%BD%AE%E4%B8%BA0%EF%BC%88RHEL%207%E4%BB%A5%E4%B8%8A%E5%88%99%E6%85%8E%E9%87%8D%E8%AE%BE%E7%BD%AE%E4%B8%BA0%EF%BC%8C%E9%99%A4%E9%9D%9E%E4%BD%A0%E5%85%81%E8%AE%B8OOM%20kill%E5%8F%91%E7%94%9F%EF%BC%89%EF%BC%8C%E4%BB%A5%E9%99%8D%E4%BD%8E%E4%BD%BF%E7%94%A8SWAP%E7%9A%84%E6%9C%BA%E4%BC%9A%EF%BC%9B%0A2%E3%80%81%E5%B0%86vm.dirty_background_ratio%E8%AE%BE%E7%BD%AE%E4%B8%BA5-10%EF%BC%8C%E5%B0%86vm.dirty_ratio%E8%AE%BE%E7%BD%AE%E4%B8%BA%E5%AE%83%E7%9A%84%E4%B8%A4%E5%80%8D%E5%B7%A6%E5%8F%B3%EF%BC%8C%E4%BB%A5%E7%A1%AE%E4%BF%9D%E8%83%BD%E6%8C%81%E7%BB%AD%E5%B0%86%E8%84%8F%E6%95%B0%E6%8D%AE%E5%88%B7%E6%96%B0%E5%88%B0%E7%A3%81%E7%9B%98%EF%BC%8C%E9%81%BF%E5%85%8D%E7%9E%AC%E9%97%B4I%2FO%E5%86%99%EF%BC%8C%E4%BA%A7%E7%94%9F%E4%B8%A5%E9%87%8D%E7%AD%89%E5%BE%85%EF%BC%88%E5%92%8CMySQL%E4%B8%AD%E7%9A%84innodb_max_dirty_pages_pct%E7%B1%BB%E4%BC%BC%EF%BC%89%EF%BC%9B%0A%0A3%E3%80%81%E5%B0%86net.ipv4.tcp_tw_recycle%E3%80%81net.ipv4.tcp_tw_reuse%E9%83%BD%E8%AE%BE%E7%BD%AE%E4%B8%BA1%EF%BC%8C%E5%87%8F%E5%B0%91TIME_WAIT%EF%BC%8C%E6%8F%90%E9%AB%98TCP%E6%95%88%E7%8E%87%EF%BC%9B%0A%0A4%E3%80%81%E8%87%B3%E4%BA%8E%E7%BD%91%E4%BC%A0%E7%9A%84read_ahead_kb%E3%80%81nr_requests%E8%BF%99%E4%B8%A4%E4%B8%AA%E5%8F%82%E6%95%B0%EF%BC%8C%E6%88%91%E7%BB%8F%E8%BF%87%E6%B5%8B%E8%AF%95%E5%90%8E%EF%BC%8C%E5%8F%91%E7%8E%B0%E5%AF%B9%E8%AF%BB%E5%86%99%E6%B7%B7%E5%90%88%E4%B8%BA%E4%B8%BB%E7%9A%84OLT%0A%60%60%60%0A%0A%23%23%23%23%23%203%E3%80%81MySQL%E5%B1%82%E7%9B%B8%E5%85%B3%E4%BC%98%E5%8C%96%0A%23%23%23%23%23%23%203.1%E3%80%81%E5%85%B3%E4%BA%8E%E7%89%88%E6%9C%AC%E9%80%89%E6%8B%A9%0A%E5%AE%98%E6%96%B9%E7%89%88%E6%9C%AC%E6%88%91%E4%BB%AC%E7%A7%B0%E4%B8%BAORACLE%20MySQL%EF%BC%8C%E8%BF%99%E4%B8%AA%E6%B2%A1%E4%BB%80%E4%B9%88%E5%A5%BD%E8%AF%B4%E7%9A%84%EF%BC%8C%E7%9B%B8%E4%BF%A1%E7%BB%9D%E5%A4%A7%E5%A4%9A%E6%95%B0%E4%BA%BA%E4%BC%9A%E9%80%89%E6%8B%A9%E5%AE%83%E3%80%82%E6%88%91%E4%B8%AA%E4%BA%BA%E5%BC%BA%E7%83%88%E5%BB%BA%E8%AE%AE%E9%80%89%E6%8B%A9Percona%E5%88%86%E6%94%AF%E7%89%88%E6%9C%AC%EF%BC%8C%E5%AE%83%E6%98%AF%E4%B8%80%E4%B8%AA%E7%9B%B8%E5%AF%B9%E6%AF%94%E8%BE%83%E6%88%90%E7%86%9F%E7%9A%84%E3%80%81%E4%BC%98%E7%A7%80%E7%9A%84MySQL%E5%88%86%E6%94%AF%E7%89%88%E6%9C%AC%EF%BC%8C%E5%9C%A8%E6%80%A7%E8%83%BD%E6%8F%90%E5%8D%87%E3%80%81%E5%8F%AF%E9%9D%A0%E6%80%A7%E3%80%81%E7%AE%A1%E7%90%86%E5%9E%8B%E6%96%B9%E9%9D%A2%E5%81%9A%E4%BA%86%E4%B8%8D%E5%B0%91%E6%94%B9%E5%96%84%E3%80%82%E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C%E7%AB%99%E6%8F%90%E4%BE%9B%E7%9A%84my.cnf%E7%94%9F%E6%88%90%E5%99%A8%E7%94%9F%E6%88%90%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6%E6%A8%A1%E6%9D%BF%EF%BC%89%EF%BC%9A%0A%60%60%60%0A1%E3%80%81%E9%80%89%E6%8B%A9Percona%E6%88%96MariaDB%E7%89%88%E6%9C%AC%E7%9A%84%E8%AF%9D%EF%BC%8C%E5%BC%BA%E7%83%88%E5%BB%BA%E8%AE%AE%E5%90%AF%E7%94%A8thread%20pool%E7%89%B9%E6%80%A7%EF%BC%8C%E5%8F%AF%E4%BD%BF%E5%BE%97%E5%9C%A8%E9%AB%98%E5%B9%B6%E5%8F%91%E7%9A%84%E6%83%85%E5%86%B5%E4%B8%8B%EF%BC%8C%E6%80%A7%E8%83%BD%E4%B8%8D%E4%BC%9A%E5%8F%91%E7%94%9F%E5%A4%A7%E5%B9%85%E4%B8%8B%E9%99%8D%E3%80%82%E6%AD%A4%E5%A4%96%EF%BC%8C%E8%BF%98%E6%9C%89extra_port%E5%8A%9F%E8%83%BD%EF%BC%8C%E9%9D%9E%E5%B8%B8%E5%AE%9E%E7%94%A8%EF%BC%8C%20%E5%85%B3%E9%94%AE%E6%97%B6%E5%88%BB%E8%83%BD%E6%95%91%E5%91%BD%E7%9A%84%E3%80%82%E8%BF%98%E6%9C%89%E5%8F%A6%E5%A4%96%E4%B8%80%E4%B8%AA%E9%87%8D%E8%A6%81%E7%89%B9%E8%89%B2%E6%98%AF%20QUERY_RESPONSE_TIME%20%E5%8A%9F%E8%83%BD%EF%BC%8C%E4%B9%9F%E8%83%BD%E4%BD%BF%E6%88%91%E4%BB%AC%E5%AF%B9%E6%95%B4%E4%BD%93%E7%9A%84SQL%E5%93%8D%E5%BA%94%E6%97%B6%E9%97%B4%E5%88%86%E5%B8%83%E6%9C%89%E7%9B%B4%E8%A7%82%E6%84%9F%E5%8F%97%EF%BC%9B%0A%0A2%E3%80%81%E8%AE%BE%E7%BD%AEdefault-storage-engine%3DInnoDB%EF%BC%8C%E4%B9%9F%E5%B0%B1%E6%98%AF%E9%BB%98%E8%AE%A4%E9%87%87%E7%94%A8InnoDB%E5%BC%95%E6%93%8E%EF%BC%8C%E5%BC%BA%E7%83%88%E5%BB%BA%E8%AE%AE%E4%B8%8D%E8%A6%81%E5%86%8D%E4%BD%BF%E7%94%A8MyISAM%E5%BC%95%E6%93%8E%E4%BA%86%EF%BC%8CInnoDB%E5%BC%95%E6%93%8E%E7%BB%9D%E5%AF%B9%E5%8F%AF%E4%BB%A5%E6%BB%A1%E8%B6%B399%25%E4%BB%A5%E4%B8%8A%E7%9A%84%E4%B8%9A%E5%8A%A1%E5%9C%BA%E6%99%AF%EF%BC%9B%0A%0A3%E3%80%81%E8%B0%83%E6%95%B4innodb_buffer_pool_size%E5%A4%A7%E5%B0%8F%EF%BC%8C%E5%A6%82%E6%9E%9C%E6%98%AF%E5%8D%95%E5%AE%9E%E4%BE%8B%E4%B8%94%E7%BB%9D%E5%A4%A7%E5%A4%9A%E6%95%B0%E6%98%AFInnoDB%E5%BC%95%E6%93%8E%E8%A1%A8%E7%9A%84%E8%AF%9D%EF%BC%8C%E5%8F%AF%E8%80%83%E8%99%91%E8%AE%BE%E7%BD%AE%E4%B8%BA%E7%89%A9%E7%90%86%E5%86%85%E5%AD%98%E7%9A%8450%25%20~%2070%25%E5%B7%A6%E5%8F%B3%EF%BC%9B%0A%0A4%E3%80%81%E6%A0%B9%E6%8D%AE%E5%AE%9E%E9%99%85%E9%9C%80%E8%A6%81%E8%AE%BE%E7%BD%AEinnodb_flush_log_at_trx_commit%E3%80%81sync_binlog%E7%9A%84%E5%80%BC%E3%80%82%E5%A6%82%E6%9E%9C%E8%A6%81%E6%B1%82%E6%95%B0%E6%8D%AE%E4%B8%8D%E8%83%BD%E4%B8%A2%E5%A4%B1%EF%BC%8C%E9%82%A3%E4%B9%88%E4%B8%A4%E4%B8%AA%E9%83%BD%E8%AE%B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E7%AB%8B%E8%A1%A8%E7%A9%BA%E9%97%B4%EF%BC%8C%E6%88%91%E5%AE%9E%E5%9C%A8%E6%98%AF%E6%83%B3%E4%B8%8D%E5%87%BA%E6%9D%A5%E7%94%A8%E5%85%B1%E4%BA%AB%E8%A1%A8%E7%A9%BA%E9%97%B4%E6%9C%89%E4%BB%80%E4%B9%88%E5%A5%BD%E5%A4%84%E4%BA%86%EF%BC%9B%0A%0A6%E3%80%81%E8%AE%BE%E7%BD%AEinnodb_data_file_path%20%3D%20ibdata1%3A1G%3Aautoextend%EF%BC%8C%E5%8D%83%E4%B8%87%E4%B8%8D%E8%A6%81%E7%94%A8%E9%BB%98%E8%AE%A4%E7%9A%8410M%EF%BC%8C%E5%90%A6%E5%88%99%E5%9C%A8%E6%9C%89%E9%AB%98%E5%B9%B6%E5%8F%91%E4%BA%8B%E5%8A%A1%E6%97%B6%EF%BC%8C%E4%BC%9A%E5%8F%97%E5%88%B0%E4%B8%8D%E5%B0%8F%E7%9A%84%E5%BD%B1%E5%93%8D%EF%BC%9B%0A%0A7%E3%80%81%E8%AE%BE%E7%BD%AEinnodb_log_file_size%3D256M%EF%BC%8C%E8%AE%BE%E7%BD%AEinnodb_log_files_in_group%3D2%EF%BC%8C%E5%9F%BA%E6%9C%AC%E5%8F%AF%E6%BB%A1%E8%B6%B390%25%E4%BB%A5%E4%B8%8A%E7%9A%84%E5%9C%BA%E6%99%AF%EF%BC%9B%0A%0A8%E3%80%81%E8%AE%BE%E7%BD%AElong_query_time%20%3D%201%EF%BC%8C%E8%80%8C%E5%9C%A85.5%E7%89%88%E6%9C%AC%E4%BB%A5%E4%B8%8A%EF%BC%8C%E5%B7%B2%E7%BB%8F%E5%8F%AF%E4%BB%A5%E8%AE%BE%E7%BD%AE%E4%B8%BA%E5%B0%8F%E4%BA%8E1%E4%BA%86%EF%BC%8C%E5%BB%BA%E8%AE%AE%E8%AE%BE%E7%BD%AE%E4%B8%BA0.05%EF%BC%8850%E6%AF%AB%E7%A7%92%EF%BC%89%EF%BC%8C%E8%AE%B0%E5%BD%95%E9%82%A3%E4%BA%9B%E6%89%A7%E8%A1%8C%E8%BE%83%E6%85%A2%E7%9A%84SQL%EF%BC%8C%E7%94%A8%E4%BA%8E%E5%90%8E%E7%BB%AD%E7%9A%84%E5%88%86%E6%9E%90%E6%8E%92%E6%9F%A5%EF%BC%9B%0A%0A9%E3%80%81%E6%A0%B9%E6%8D%AE%E4%B8%9A%E5%8A%A1%E5%AE%9E%E9%99%85%E9%9C%80%E8%A6%81%EF%BC%8C%E9%80%82%E5%BD%93%E8%B0%83%E6%95%B4max_connection%EF%BC%88%E6%9C%80%E5%A4%A7%E8%BF%9E%E6%8E%A5%E6%95%B0%EF%BC%89%E3%80%81max_connection_error%EF%BC%88%E6%9C%80%E5%A4%A7%E9%94%99%E8%AF%AF%E6%95%B0%EF%BC%8C%E5%BB%BA%E8%AE%AE%E8%AE%BE%E7%BD%AE%E4%B8%BA10%E4%B8%87%E4%BB%A5%E4%B8%8A%EF%BC%8C%E8%80%8Copen_files_limit%E3%80%81innodb_open_files%E3%80%81table_open_cache%E3%80%81table_definition_cache%E8%BF%99%E5%87%A0%E4%B8%AA%E5%8F%82%E6%95%B0%E5%88%99%E5%8F%AF%E8%AE%BE%E4%B8%BA%E7%BA%A610%E5%80%8D%E4%BA%8Emax_connection%E7%9A%84%E5%A4%A7%E5%B0%8F%EF%BC%9B%0A%0A10%E3%80%81%E5%B8%B8%E8%A7%81%E7%9A%84%E8%AF%AF%E5%8C%BA%E6%98%AF%E6%8A%8Atmp_table_size%E5%92%8Cmax_heap_table_size%E8%AE%BE%E7%BD%AE%E7%9A%84%E6%AF%94%E8%BE%83%E5%A4%A7%EF%BC%8C%E6%9B%BE%E7%BB%8F%E8%A7%81%E8%BF%87%E8%AE%BE%E7%BD%AE%E4%B8%BA1G%E7%9A%84%EF%BC%8C%E8%BF%992%E4%B8%AA%E9%80%89%E9%A1%B9%E6%98%AF%E6%AF%8F%E4%B8%AA%E8%BF%9E%E6%8E%A5%E4%BC%9A%E8%AF%9D%E9%83%BD%E4%BC%9A%E5%88%86%E9%85%8D%E7%9A%84%EF%BC%8C%E5%9B%A0%E6%AD%A4%E4%B8%8D%E8%A6%81%E8%AE%BE%E7%BD%AE%E8%BF%87%E5%A4%A7%EF%BC%8C%E5%90%A6%E5%88%99%E5%AE%B9%E6%98%93%E5%AF%BC%E8%87%B4OOM%E5%8F%91%E7%94%9F%EF%BC%9B%E5%85%B6%E4%BB%96%E7%9A%84%E4%B8%80%E4%BA%9B%E8%BF%9E%E6%8E%A5%E4%BC%9A%E8%AF%9D%E7%BA%A7%E9%80%89%E9%A1%B9%E4%BE%8B%E5%A6%82%EF%BC%9Asort_buffer_size%E3%80%81join_buffer_size%E3%80%81read_buffer_size%E3%80%81read_rnd_buffer_size%E7%AD%89%EF%BC%8C%E4%B9%9F%E9%9C%80%E8%A6%81%E6%B3%A8%E6%84%8F%E4%B8%8D%E8%83%BD%E8%AE%BE%E7%BD%AE%E8%BF%87%E5%A4%A7%EF%BC%9B%0A%0A11%E3%80%81%E7%94%B1%E4%BA%8E%E5%B7%B2%E7%BB%8F%E5%BB%BA%E8%AE%AE%E4%B8%8D%E5%86%8D%E4%BD%BF%E7%94%A8MyISAM%E5%BC%95%E6%93%8E%E4%BA%86%EF%BC%8C%E5%9B%A0%E6%AD%A4%E5%8F%AF%E4%BB%A5%E6%8A%8Akey_buffer_size%E8%AE%BE%E7%BD%AE%E4%B8%BA32M%E5%B7%A6%E5%8F%B3%EF%BC%8C%E5%B9%B6%E4%B8%94%E5%BC%BA%E7%83%88%E5%BB%BA%E8%AE%AE%E5%85%B3%E9%97%ADquery%20cache%E5%8A%9F%E8%83%BD%EF%BC%9B%0A%60%60%60%0A%23%23%23%23%23%23%203.3%E3%80%81%E5%85%B3%E4%BA%8ESchema%E8%AE%BE%E8%AE%A1%E8%A7%84%E8%8C%83%E5%8F%8ASQL%E4%BD%BF%E7%94%A8%E5%BB%BA%E8%AE%AE%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A1%E5%BF%85%E8%A6%81%E5%86%8D%E8%B7%91%E5%A4%9A%E5%AE%9E%E4%BE%8B%E4%BA%86%EF%BC%9B%0A%0A4%E3%80%81%E5%AE%9A%E6%9C%9F%E4%BD%BF%E7%94%A8pt-duplicate-key-checker%E6%A3%80%E6%9F%A5%E5%B9%B6%E5%88%A0%E9%99%A4%E9%87%8D%E5%A4%8D%E7%9A%84%E7%B4%A2%E5%BC%95%E3%80%82%E5%AE%9A%E6%9C%9F%E4%BD%BF%E7%94%A8pt-index-usage%E5%B7%A5%E5%85%B7%E6%A3%80%E6%9F%A5%E5%B9%B6%E5%88%A0%E9%99%A4%E4%BD%BF%E7%94%A8%E9%A2%91%E7%8E%87%E5%BE%88%E4%BD%8E%E7%9A%84%E7%B4%A2%E5%BC%95%EF%BC%9B%0A%0A5%E3%80%81%E5%AE%9A%E6%9C%9F%E9%87%87%E9%9B%86slow%20query%20log%EF%BC%8C%E7%94%A8pt-query-digest%E5%B7%A5%E5%85%B7%E8%BF%9B%E8%A1%8C%E5%88%86%E6%9E%90%EF%BC%8C%E5%8F%AF%E7%BB%93%E5%90%88Anemometer%E7%B3%BB%E7%BB%9F%E8%BF%9B%E8%A1%8Cslow%20query%E7%AE%A1%E7%90%86%E4%BB%A5%E4%BE%BF%E5%88%86%E6%9E%90slow%20query%E5%B9%B6%E8%BF%9B%E8%A1%8C%E5%90%8E%E7%BB%AD%E4%BC%98%E5%8C%96%E5%B7%A5%E4%BD%9C%EF%BC%9B%0A%0A6%E3%80%81%E5%8F%AF%E4%BD%BF%E7%94%A8pt-kill%E6%9D%80%E6%8E%89%E8%B6%85%E9%95%BF%E6%97%B6%E9%97%B4%E7%9A%84SQL%E8%AF%B7%E6%B1%82%EF%BC%8CPercona%E7%89%88%E6%9C%AC%E4%B8%AD%E6%9C%89%E4%B8%AA%E9%80%89%E9%A1%B9%20innodb_kill_idle_transaction%20%E4%B9%9F%E5%8F%AF%E5%AE%9E%E7%8E%B0%E8%AF%A5%E5%8A%9F%E8%83%BD%EF%BC%9B%0A%0A7%E3%80%81%E4%BD%BF%E7%94%A8pt-online-schema-change%E6%9D%A5%E5%AE%8C%E6%88%90%E5%A4%A7%E8%A1%A8%E7%9A%84ONLINE%20DDL%E9%9C%80%E6%B1%82%EF%BC%9B%0A%0A8%E3%80%81%E5%AE%9A%E6%9C%9F%E4%BD%BF%E7%94%A8pt-table-checksum%E3%80%81pt-table-sync%E6%9D%A5%E6%A3%80%E6%9F%A5%E5%B9%B6%E4%BF%AE%E5%A4%8Dmysql%E4%B8%BB%E4%BB%8E%E5%A4%8D%E5%88%B6%E7%9A%84%E6%95%B0%E6%8D%AE%E5%B7%AE%E5%BC%82%EF%BC%9B%60%0A%60%60%60


以上是关于Mysql 优化建议的主要内容,如果未能解决你的问题,请参考以下文章

全栈数据之Mysql数据库优化建议

MYSQL性能优化以及建议

MySQL 调优/优化的 100 个建议

vscode代码片段建议bug

优化 C# 代码片段、ObservableCollection 和 AddRange

有没有办法关闭代码片段中的命名建议?