安定北京被性能测试困扰了N天,实在没想法去解决了,今天又收到上级的命令说安定北京要解决,无奈!把项目组唯一的DBA辞掉了,现在所以数据库的问题都得自己来处理:( 不知道上边人怎么想的。而且更不知道怎安定北京么想的是居然会把应用部属在虚拟主机上!唉。。。 不唠叨了 说说处理过程吧: 1.在终端里set profiling=1; 2.输入要调整的SQL语句,比如select * from table1; 3.输入show profiles;看看刚才那条语句的ID 用于后面分析 4.show profile for query 2; 5.show profile block io,cpu for query 2; 6.show profile cpu,block io,memory,swaps,context switches,source for query 5; 7.通过上面的一些查询 大体可以看出这条SQL语句执行的时候哪些地方占用的时间太大了。这次测试看到的是Copying to tmp table on disk和converting HEAP to MyISAM占有的时间太多。网上查了一下发现可以修改一下tmp_table_size和max_heap_table_size两个参数来调整,使得大数据量的查询时不用将结果集拷贝到物理磁盘。这样时间就争取过来了 对了 MYSQL有个好用的命令可以分析一条SQL的结构,可以查到这个查询是否使用到索引等。直接explain select * from table1就行了 +--------------------------------+------------+------------+------------+-------------------+---------------------+--------------+---------------+-------+---------------------------+---------------+-------------+ | Status                         | Duration   | CPU_user   | CPU_system | Context_voluntary | Context_involuntary | Block_ops_in | Block_ops_out | Swaps | Source_function           | Source_file   | Source_line | +--------------------------------+------------+------------+------------+-------------------+---------------------+--------------+---------------+-------+---------------------------+---------------+-------------+ | checking query cache for query | 0.00001100 | 0.00000000 | 0.00000000 |                 0 |                   0 |            0 |             0 |     0 | send_result_to_client     | sql_cache.cc  |        1094 | | Opening tables                 | 0.00023400 | 0.00000000 | 0.00000000 |                 0 |                   0 |            0 |             0 |     0 | open_tables               | sql_base.cc   |        2106 | | System lock                    | 0.00002800 | 0.00000000 | 0.00000000 |                 0 |                   0 |            0 |             0 |     0 | mysql_lock_tables         | lock.cc       |         153 | | Table lock                     | 0.00001300 | 0.00000000 | 0.00000000 |                 0 |                   0 |            0 |             0 |     0 | mysql_lock_tables         | lock.cc       |         162 | | optimizing                     | 0.00022700 | 0.00099900 | 0.00000000 |                 0 |                   0 |            0 |             0 |     0 | optimize                  | sql_select.cc |         617 | | statistics                     | 0.00002900 | 0.00000000 | 0.00000000 |                 0 |                   0 |            0 |             0 |     0 | optimize                  | sql_select.cc |         773 | | preparing                      | 0.00012800 | 0.00000000 | 0.00000000 |                 0 |                   0 |            0 |             0 |     0 | optimize                  | sql_select.cc |         783 | | Creating tmp table             | 0.00003400 | 0.00000000 | 0.00000000 |                 0 |                   0 |            0 |             0 |     0 | optimize                  | sql_select.cc |        1206 | | executing                      | 0.00003100 | 0.00000000 | 0.00000000 |                 0 |                   0 |            0 |             0 |     0 | exec                      | sql_select.cc |        1407 | | Copying to tmp table           | 0.00001100 | 0.00000000 | 0.00000000 |                 0 |                   0 |            0 |             0 |     0 | exec                      | sql_select.cc |        1547 | | converting HEAP to MyISAM      | 3.94055900 | 3.81042100 | 0.12498100 |                 6 |                   7 |            0 |             0 |     0 | create_myisam_from_heap   | sql_select.cc |        9914 | | Copying to tmp table on disk   | 5.10490400 | 5.00623900 | 0.09798500 |                 8 |                  10 |            0 |             0 |     0 | create_myisam_from_heap   | sql_select.cc |        9968 | | Sending data                   | 3.09531800 | 2.96954900 | 0.12698100 |                 4 |                   4 |            0 |             0 |     0 | exec                      | sql_select.cc |        1925 | | converting HEAP to MyISAM      | 1.62242300 | 1.37279100 | 0.25096200 |                38 |                  15 |            0 |             0 |     0 | create_myisam_from_heap   | sql_select.cc |        9914 | | Sending data                   | 5.13815600 | 5.04223300 | 0.09698500 |                13 |                  10 |            0 |             0 |     0 | create_myisam_from_heap   | sql_select.cc |        9968 | | optimizing                     | 2.17403900 | 2.01069500 | 0.16497500 |                 5 |                   3 |            0 |             0 |     0 | optimize                  | sql_select.cc |         617 | mysql官网论坛也有讲过这配置 但没说到第二项配置 http://forums.mysql.com/read.php?22,111012,111012#msg-111012



-————————————————————————————————————————————————————————————————————————————————————————————————————

http://www.mysqlab.net/knowledge/kb/detail/topic/myisam/id/6149

Discussion

The state "converting HEAP to MyISAM" happens when a query that needs a temporary table is converting from an in-memory temporary table to a disk-based temporary table.

MySQL uses memory-based temporary tables up to the size limit set by the tmp_table_size system variable. If a query needs a temporary table larger than this it will be converted to a disk-based temporary table using the MyISAM storage engine.

GROUP BY queries and ORDER BY queries that can't use an index for the ordering are the most common causes of temporary table creation.

Solution

You could consider raising the per-session value of tmp_table_size if you have sufficient memory. Use the SHOW GLOBAL STATUS statement to see the value of the Created_tmp_tables variable. It will show the total number of temporary tables that have been created:

  1. SHOW GLOBAL STATUS LIKE 'Created_tmp_tables';
  2.  
  3. +--------------------+-------+
  4. | Variable_name | Value |
  5. +--------------------+-------+
  6. | Created_tmp_tables | 13 |
  7. +--------------------+-------+

The

Created_tmp_disk_tables

variable shows how many of those have been converted to disk temporary tables:

  1. SHOW GLOBAL STATUS LIKE 'Created_tmp_disk_tables';
  2.  
  3. +-------------------------+-------+
  4. | Variable_name | Value |
  5. +-------------------------+-------+
  6. | Created_tmp_disk_tables | 1 |
  7. +-------------------------+-------+

调2个参数

tmp_table_size和max_heap_table_size ============> converting HEAP to MyISAM

mysql性能问题小解 Converting HEAP to MyIsam create_myisa的更多相关文章

  1. mysql性能优化-慢查询分析、优化索引和配置

    一.优化概述 二.查询与索引优化分析 1性能瓶颈定位 Show命令 慢查询日志 explain分析查询 profiling分析查询 2索引及查询优化 三.配置优化 1)      max_connec ...

  2. MySQL性能优化笔记整理

    一.测试篇 1.测试目的,就是量化找出短板(基础参数配置) 2.测试三大指标 IOPS:每秒处理的IO请求数,即IO响应速度(注意和IO吞吐量的区别) QPS:每秒请求(查询)次数 TPS:每秒事务数 ...

  3. [转]mysql性能优化-慢查询分析、优化索引和配置

    一. 优化概述 MySQL数据库是常见的两个瓶颈是CPU和I/O的瓶颈,CPU在饱和的时候一般发生在数据装入内存或从磁盘上读取数据时候.磁盘I/O瓶颈发生在装入数据远大于内存容量的时候,如果应用分布在 ...

  4. mysql性能优化-慢查询分析、优化索引和配置 (慢查询日志,explain,profile)

    mysql性能优化-慢查询分析.优化索引和配置 (慢查询日志,explain,profile) 一.优化概述 二.查询与索引优化分析 1性能瓶颈定位 Show命令 慢查询日志 explain分析查询 ...

  5. mysql性能优化-慢查询分析、优化索引和配置【转】

    一.优化概述 二.查询与索引优化分析 1性能瓶颈定位 Show命令 慢查询日志 explain分析查询 profiling分析查询 2索引及查询优化 三.配置优化 1)      max_connec ...

  6. MySQL 性能优化技巧

    原文地址:MySQL 性能优化技巧 博客地址:http://www.extlight.com 一.背景 最近公司项目添加新功能,上线后发现有些功能的列表查询时间很久.原因是新功能用到旧功能的接口,而这 ...

  7. MySQL性能调优思路

    1.MySQL性能调优思路 如果一台服务器出现长时间负载过高 /周期性负载过大,或偶尔卡住如何来处理? 是周期性的变化还是偶尔问题?是服务器整体性能的问题, 还是某单条语句的问题? 具体到单条语句, ...

  8. mysql性能优化-慢查询分析、优化索引和配置 MySQL索引介绍

    MySQL索引介绍 聚集索引(Clustered Index)----叶子节点存放整行记录辅助索引(Secondary Index)----叶子节点存放row identifier-------Inn ...

  9. 9.mysql性能优化-慢查询分析、优化索引和配置

    目录 一.优化概述 二.查询与索引优化分析 1性能瓶颈定位 Show命令 慢查询日志 explain分析查询 profiling分析查询 2索引及查询优化 三.配置优化 max_connections ...

随机推荐

  1. Ubuntu16.04安装视觉SLAM环境(g2o)

    1.首先在github上下载g2o图优化库 git clone https://github.com/RainerKuemmerle/g2o.git 2.运行安装以下依赖库 sudo apt-get ...

  2. 通过js获取内网ip和外网ip的简单方法 ...

    今天遇到了一个需求,需要获取用户当前的内网ip, 找了半天终于找到了方法,遂将找到的方法记录下来,留给需要的人. 1,获取内网ip function getIP(callback) { let rec ...

  3. [转] Spark sql 内置配置(V2.2)

    [From] https://blog.csdn.net/u010990043/article/details/82842995 最近整理了一下spark SQL内置配.加粗配置项是对sparkSQL ...

  4. 何为Web App,何为Hybird App

    这些概念听起来很火,当下也很流行,真正理解起来却并非易事.如果让我来全面的解释Web App和Hybird App,我觉得还有些困难. 这篇文章只是我深入了解移动领域开发过程中的不断整理和总结,其中涉 ...

  5. JVM-类加载过程(Java类的生命周期)

    什么是类加载 类的加载指的是将类的.class文件中的二进制数据读入到内存中,将其放在运行时数据区的方法区内,然后在堆区创建一个java.lang.Class对象,用来封装类在方法区内的数据结构.类的 ...

  6. Window.localStorage

    博客园 https://www.cnblogs.com/st-leslie/p/5617130.html 参考文档 https://developer.mozilla.org/zh-CN/docs/W ...

  7. 关于chrome浏览器事件拖动的bug(首次点击的时候也触发move的事件)

    在做R80web的时候出现一个奇怪的现象,chorme现在的版本还是存在,拖动事件有mousedown.mousemove.mouseup组成,但是首次click以及失去焦点再重新点击的时候同样会触发 ...

  8. rspec中的let和let!区别

    文档 https://relishapp.com/rspec/rspec-core/v/2-5/docs/helper-methods/let-and-let 从上面文档中得出 let 1 只会在一个 ...

  9. *2.2.4 加入virtual interface

    在前几节的例子中,driver中等待时钟事件(@posedge top.clk).给DUT中输入端口赋值(top.rx_dv <= 1' b1)都是使用绝对路径,绝对路径的使用大大减弱了验证平台 ...

  10. iOS开源项目周报0316

    由OpenDigg 出品的iOS开源项目周报第十二期来啦.我们的iOS开源周报集合了OpenDigg一周来新收录的优质的iOS开源项目,方便iOS开发人员便捷的找到自己需要的项目工具等.GodEye  ...