+-----+--------+-----------+--------------+---------+------+----------------------+---------+
| Id  | User   | Host      | db           | Command | Time | State                | Info                                                                                                |
+-----+--------+-----------+--------------+---------+------+----------------------+---------+
|   7 | echina | localhost | echinacities | Query   |   19 | Locked               | 
|  31 | echina | localhost | echinacities | Query   |   22 | Locked               | 
| 408 | echina | localhost | echinacities | Query   |   22 | Locked               | 
| 464 | echina | localhost | echinacities | Query   |   22 | Locked               | 
| 471 | echina | localhost | echinacities | Query   |   21 | Locked               | 
| 499 | echina | localhost | echinacities | Query   |   22 | Copying to tmp table | 
| 545 | echina | localhost | echinacities | Query   |   22 | Locked               | 
| 569 | echina | localhost | echinacities | Query   |   22 | Locked               | 
| 588 | echina | localhost | echinacities | Query   |   21 | Locked               | 
| 589 | echina | localhost | echinacities | Query   |   21 | Locked               | 
| 602 | echina | localhost | echinacities | Query   |   22 | Locked               | 
| 624 | echina | localhost | echinacities | Query   |   21 | Locked               | 
| 647 | echina | localhost | echinacities | Query   |   19 | Locked               | 
| 651 | echina | localhost | echinacities | Query   |   22 | Locked               | 
| 680 | echina | localhost | echinacities | Query   |   22 | Locked               | 
| 681 | echina | localhost | echinacities | Query   |   21 | Locked               | 
| 688 | echina | localhost | echinacities | Query   |   17 | Locked               | 
| 704 | echina | localhost | echinacities | Query   |   22 | Locked               | 
| 709 | echina | localhost | echinacities | Query   |   21 | Locked               | 
| 710 | echina | localhost | echinacities | Query   |   20 | Locked               | 
| 711 | echina | localhost | echinacities | Query   |   20 | Locked               | 
| 713 | echina | localhost | echinacities | Query   |   19 | Locked               | 
| 718 | echina | localhost | echinacities | Query   |   12 | Locked               | 
| 720 | echina | localhost | echinacities | Query   |   18 | Locked               | 
| 729 | echina | localhost | echinacities | Query   |   16 | Locked               | 
| 731 | echina | localhost | echinacities | Query   |   15 | Locked               | 
| 745 | echina | localhost | echinacities | Sleep   |   11 |                      | 
| 746 | echina | localhost | echinacities | Query   |   11 | Locked               | 
| 748 | echina | localhost | echinacities | Sleep   |   10 |                      | 
| 749 | echina | localhost | echinacities | Query   |   10 | Locked               | 
+-----+--------+-----------+--------------+---------+------+----------------------+-
 
 
mysql默认
tmp_table_size 33554432 (33.5M)
max_heap_table_size 16777216 (16.7M)
 
copy to tmp table的SQL语句,这条语读的时间比较长,且这个表会被加读锁,相关表的update语句会被排进队列。如果多执行几次这样的copyt to tmp table 语句,会造成更多的语句被阻塞。
连接太多造成mysql处理慢。
copy to tmp talbe 语句产生的原因是查询需要Order By 或者Group By等需要用到结果集时,参数中设置的临时表的大小小于结果集的大小时,就会将该表放在磁盘上,这个时候在硬盘上的IO要比内销差很多。所耗费的时间也多很多。另外Mysql的另外一个参数max_heap_table_size比tmp_table_size小时,则系统会把 max_heap_table_size的值作为最大的内存临时表的上限,大于这个时,改写硬盘。
 
内存临时表=min(max_heap_table_size,tmp_table_size)
 
kill 499
 

copy to tmp table的更多相关文章

  1. mysql 查询copy to tmp table造成堵塞

    show full PROCESSLIST; show VARIABLES like 'tmp_table_size' set GLOBAL tmp_table_size=629145600; SHO ...

  2. mysql-copy to tmp table

    今天数据后台数据反映有些迟缓后查看链接 processlist 发下好多 锁 和磁盘写入,   参考文章 : http://bbs.chinaunix.net/forum.php?mod=viewth ...

  3. How to Quickly Create a Copy of a Table using Transact-SQL

    The easiest way to create a copy of a table is to use a Transact-SQL command. Use SELECT INTO to ext ...

  4. MySQL 优化 之 Copying to tmp table on disk

    项目中遇到了慢查询问题 Sql语句 SELECT sum(price) AS price, `member_id` FROM `crm_upload` GROUP BY member_id ORDER ...

  5. 一条sql语句引发mysql不停创建临时表的问题解决..coping to tmp table on desk

    (不懂临时表的先看 MySQL临时表 ) 首先,临时表只在当前连接可见,当关闭连接时,Mysql会自动删除表并释放所有空间.因此在不同的连接中可以创建同名的临时表,并且操作属于本连接的临时表.     ...

  6. 【待整理】MySQL alter table modify vs alter table add产生state不一样

    MySQL:5.6.35 OS:redhat5.8 今天更新数据库某些表字段,有如下两SQL: ①alter table xx modify xxxx;(表大概是77w) ②alter table s ...

  7. 翻译:MariaDB ALTER TABLE语句

    */ .hljs { display: block; overflow-x: auto; padding: 0.5em; color: #333; background: #f8f8f8; } .hl ...

  8. 修改字段字符集 mysql 修改 锁表 show processlist; 查看进程 Waiting for table metadata lock

    ALTER TABLE `question` MODIFY COLUMN `title` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unico ...

  9. [MySQL Reference Manual] 23 Performance Schema结构

    23 MySQL Performance Schema 23 MySQL Performance Schema 23.1 性能框架快速启动 23.2 性能框架配置 23.2.1 性能框架编译时配置 2 ...

随机推荐

  1. bash脚本编写基础

    bash脚本编程     命令的堆砌     脚本程序:解释器解析执行     shell:交互式接口,编程环境         shell:能够提供一些内部命令,并且能通过PATH环境变量找到外部命 ...

  2. python 模块相互import

    模块A中import B,而在模块B中import A.这时会怎么样呢?这个在Python列表中由RobertChen给出了详细解释,抄录如下: [A.py] from B import D clas ...

  3. 基于JQuery的WEB套打设计器jatoolsPrinter1.0

    开发web套打应用时,如快递单打印,一般要经过以下步骤:1. 扫描快递单据,保存成一个图片文件2. 将底图作成<img>3. 在<img>上放置打印项,试着打印到打印机,观察有 ...

  4. chardet的下载及安装

    1.chardet下载地址 https://pypi.python.org/pypi/chardet/3.0.4#downloads 2.解压至安装路径 D:\Program Files (x86)\ ...

  5. 大数相减 C语言

    #include <stdio.h> #include <string.h> using namespace std; ],b[]; void Sub() { ; if(a = ...

  6. 【转】C#学习之用迭代器实现枚举器

    http://www.cnblogs.com/zouzf/archive/2012/02/22/2362954.html 本人初学C#,本文仅供个人整理思路用,那里说得不对,请大家多多指教,万分感激! ...

  7. struts拦截器详解

    拦截器是Struts2最强大的特性之一,它是一种可以让用户在Action执行之前和Result执行之后进行一些功能处理的机制. 说到拦截器interceptor,就会想到过滤器filter: 过滤器f ...

  8. SpriteKit-(SKNode)

    1.初始化 + (instancetype)node; + (nullable instancetype)nodeWithFileNamed:(NSString*)filename; 2.返回边界边框 ...

  9. HDU——1272小希的迷宫(并查集+拓扑排序)

    小希的迷宫 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Subm ...

  10. HUST-1407 郁闷的小J

    离线做法:分别处理每个编号上的各种询问和操作,接着就能用树状数组维护. #include <cstdlib> #include <cstdio> #include <cs ...