今天数据后台数据反映有些迟缓后查看链接 processlist 发下好多 锁 和磁盘写入,
 
参考文章 : http://bbs.chinaunix.net/forum.php?mod=viewthread&tid=3646279
http://www.cnblogs.com/JulyZhang/archive/2011/01/28/1947165.html
 
+-----+--------+-----------+--------------+---------+------+----------------------+---------+
| 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的值作为最大的内存临时表的上限,大于这个时,改写硬盘。
 

mysql-copy to tmp table的更多相关文章

  1. copy to tmp table

    +-----+--------+-----------+--------------+---------+------+----------------------+---------+ | Id   ...

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

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

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

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

  4. mysql copy表或表数据常用的语句整理汇总

    mysql copy表或表数据常用的语句整理汇总. 假如我们有以下这样一个表: id username password ----------------------------------- 1 a ...

  5. mysql批量进行optimize table操作

    数据库运行一段时间后,有可能会有磁盘磁片产生,此时我们需要进行optimize table操作 # 获取需要optimize的表:如下为获取总大小小于80G的表进行操作:mysql -utroot - ...

  6. MySQL出现Waiting for table metadata lock的原因以及解决方法

    转自:http://ctripmysqldba.iteye.com/blog/1938150 (有修改) MySQL在进行alter table等DDL操作时,有时会出现Waiting for tab ...

  7. 【转】【MySql】Waiting for table metadata lock原因分析

    MySQL在进行alter table等DDL操作时,有时会出现Waiting for table metadata lock的等待场景.而且,一旦alter table TableA的操作停滞在Wa ...

  8. 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 ...

  9. detecting locked tables mysql (locked by LOCK TABLE)

    detecting locked tables mysql (locked by LOCK TABLE) up vote15down votefavorite 7 I would like to kn ...

随机推荐

  1. metaclass元类解析

    一.创建类的流程 二.什么是元类 在Python3中继承type的就是元类 示例 # 方式一 class MyType(type): '''继承type的就是元类''' def __init__(se ...

  2. 如何在VS中快速导入新的源码以及文件夹

    参考链接:http://www.cjjjs.com/paper/xmkf/201641716212844.aspx 在visual studio 2013中尝试发现的问题:原文中“显示所有文件 ”的操 ...

  3. 【ros】【bug】gtk2\3 冲突

    ORBSLAM2首次运行出现GTK冲突. Gtk-ERROR **: GTK+ 3 symbols detected. Using GTK+ 2.x and GTK+ 3 in the same pr ...

  4. grafana快速入门

    入门 本指南将帮助您开始并熟悉Grafana.它假定您有一台正在运行的Grafana服务器,并至少添加了一个数据源. 初学者指南 观看10分钟的初学者指南,以建立仪表板,以快速介绍设置仪表板和面板. ...

  5. 永洪BI——国内领军的一站式大数据分析平台

    平台: CentOS 类型: 虚拟机镜像 软件包: jdk-7.79-linux yonghongbi.sh basic software big data business intelligence ...

  6. python3基础01(常见语法基础汇总)

    #!/usr/bin/env python# -*- coding:utf-8 -*- # 换行\n 续行\ s[:i] + s[i:] 等于 s#转义 \e 空 \000 八进制 \oyy 十六进制 ...

  7. Html+css实现带图标的控件

    </pre><pre name="code" class="html"><!DOCTYPE html> <html l ...

  8. 2018.5.20 oracle强化练习

    --现在有一个商店的数据库,记录客户以及购物的情况, 商品表goods (商品号 goodsid varchar2(8) 商品名 goodsname varchar2(20) 单价 unitprice ...

  9. python_46_输出

    name='Qi Zhiguang' name2='ZhangMeng' print("Hi!"+name)#用加号,后边must be str print('Hi!',name) ...

  10. 在maven项目中 配置代理对象远程调用crm

    1 在maven项目中配置代理对象远程调用crm 1.1 在项目的pom.xml中引入CXF的依赖 <dependency> <groupId>org.apache.cxf&l ...