- 1、本文档共29页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
如何理解mysql执行计划教程
如何理解Mysql执行计划;
我们已经能够用tcpdump+ percona tookit的pt-query-digest来获取mysql的
语句。在得到查询比较慢的sql时,我们需要知道查询慢在哪?;目录;Mysql的逻辑体系结构;查询的过程以及开销;查询性能低下的原因;SQL标准的执行流程(select);SQL标准的执行流程;sql中的join;nested loop join算法(对连接的优化);原理分析;explain的输出;explain的输出;type的类型(1);type的类型(2);type的类型(3);type的类型(4);type的类型(5);type的类型(6);Key相关;others;extra;extra;案例分析;Explain分析;;
补充:
Temporary Tables
In some cases, the server creates internal temporary tables while processing queries. Such a table can be held in memory and processed by the?MEMORY?storage engine, or stored on disk and processed by the?MyISAM?storage engine. The server may create a temporary table initially as an in-memory table, then convert it to an on-disk table if it becomes too large.?
临时表占用内存比较大时,超过?tmp_table_size and max_heap_table_size 的values值后会交换到磁盘
filesort
如果order by没有使用索引或者和groupby的字段不一样,执行计划中extra就会出现filesort,执行过程如下
1. Read the rows that match the?WHERE?clause.
2. For each row, record a tuple of values consisting of the sort key value and the columns referenced by the query.
3. When the sort buffer becomes full, sort the tuples by sort key value in memory and write it to a temporary file.
4. After merge-sorting the temporary file, retrieve the rows in sorted order, but read the required columns directly from the sorted tuples rather than by accessing the table a second time.
需要排序的行比较多的时,会出现sort buffer溢出,出现磁盘I/O,同时也消耗CPU 影响性能
;
参考资料:
1. MySQL中Join算法实现原理分析
/art/200904/117947.htm
2. Mysql explain的输出
/persister/archive/2008/10/27/236813.html
3.图解sql的join
/articles/3463.html?
4. How MySQL Uses Internal Temporary Tables
/doc/refman/5.1/en/internal-temporary-tables.html
5. MySQL使用rand获取随机记录的性能优化问题
/iefreer/article/details6. MYSQL执行流程的简单探讨
/index.php/161.html
7.Filesort
/doc/refman/5.6/en/order-by-optimization.html
8. emporary-tables
/doc/refman/5.7/en/internal-temporary-tables.html
;THANK YOU
您可能关注的文档
- 如何写好作文的结尾教程.ppt
- 如何写出高质量代码教程.pptx
- 如何写好作文的开头ppt课件教程.ppt
- 如何准确地从文言文中筛选并提取信息教程.ppt
- 如何减轻静脉穿刺的疼痛教程.ppt
- 乘车应系好安全带.ppt
- 如何制作PPT模板?教程.ppt
- 如何制定检索式教程.ppt
- 乌镇雅园户型案例分析.pptx
- 乒乓球比赛执行案.pptx
- 第十一章 电流和电路专题特训二 实物图与电路图的互画 教学设计 2024-2025学年鲁科版物理九年级上册.docx
- 人教版七年级上册信息技术6.3加工音频素材 教学设计.docx
- 5.1自然地理环境的整体性 说课教案 (1).docx
- 4.1 夯实法治基础 教学设计-2023-2024学年统编版九年级道德与法治上册.docx
- 3.1 光的色彩 颜色 电子教案 2023-2024学年苏科版为了八年级上学期.docx
- 小学体育与健康 四年级下册健康教育 教案.docx
- 2024-2025学年初中数学九年级下册北京课改版(2024)教学设计合集.docx
- 2024-2025学年初中科学七年级下册浙教版(2024)教学设计合集.docx
- 2024-2025学年小学信息技术(信息科技)六年级下册浙摄影版(2013)教学设计合集.docx
- 2024-2025学年小学美术二年级下册人美版(常锐伦、欧京海)教学设计合集.docx
文档评论(0)