+-----+--------+-----------+--------------+---------+------+----------------------+---------+
| 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. 使用sprunge粘贴文字

    在irc里面请教的时候,需要输出很多文本,irc禁止输入多行文字. 使用sprunge可以返回一个网址,省去复制粘贴的麻烦. 1> 简单使用: command | curl -F "s ...

  2. 下拉列表 Spinner

    在Web开发中,HTML提供了下拉列表的实现,就是使用<select>元素实现一个下拉列表,在其中每个下拉列表项使用<option>表示即可.这是在Web开发中一个必不可少的交 ...

  3. vi 编辑器命令

    插入命令 a append after the cursor A append after the current line i insert before the cursor I insert b ...

  4. 用PHP写的一个简单的分页类 2.0版

    <?php /* 分页类 用于实现对多条数据分页显示 version:2.0 //基于1.0 数据库查询用mysqli实现 author:Knight E-Mail:S.Knight.Work@ ...

  5. 服务器迁移至Linux操作系统

    我在这里试了ubuntu.Debian,centos.最终还是选择了centos 使用工具putty,远程桌面的话使用vnc viewer(看起来service文件更改只需要替换user,但是路径不对 ...

  6. Spring AOP(面向切面)

    什么是AOP?基本概念切面(aspect):横切关注点被模块化的特殊对象.通知(advice):切面必须要完成的工作.切面中的每个方向称之为通知.通知是在切面对象中的.目标(target):被通知的对 ...

  7. iOS--app自定义相册--给图片重写exif数据-定义相册时间戳

    1.Exif简介 可交换图像文件格式常被简称为Exif(Exchangeable image file format),是专门为数码相机的照片设定的,可以记录数码照片的属性信息和拍摄数据. Exif可 ...

  8. 【Luogu】P1430序列取数(DP)

    题目链接 博弈DP太喵了qwq 设f[i][j]表示剩下区间[i,j]要取,先手最大值 明显我们要从这区间里面拿个最大的 就等价于这段区间的前缀和,我们要给对手留下个最小的 就是f[i][j]=sum ...

  9. 【Luogu】P2045方格取数加强版(最小费用最大流)

    题目链接 通过这题我学会了引诱算法的行为,就是你通过适当的状态设计,引诱算法按照你想要它做的去行动,进而达到解题的目的. 最小费用最大流,首先将点拆点,入点和出点连一条费用=-权值,容量=1的边,再连 ...

  10. [luoguP2601] [ZJOI2009]对称的正方形(二维Hash + 二分 || Manacher)

    传送门 很蒙蔽,不知道怎么搞. 网上看题解有说可以哈希+二分搞,也有的人说用Manacher搞,Manacher是什么鬼?以后再学. 对于这个题,可以从矩阵4个角hash一遍,然后枚举矩阵中的点,再二 ...