今天数据后台数据反映有些迟缓后查看链接 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的值作为最大的内存临时表的上限,大于这个时,改写硬盘。
- copy to tmp table
+-----+--------+-----------+--------------+---------+------+----------------------+---------+ | Id ...
- mysql 查询copy to tmp table造成堵塞
show full PROCESSLIST; show VARIABLES like 'tmp_table_size' set GLOBAL tmp_table_size=629145600; SHO ...
- MySQL 优化 之 Copying to tmp table on disk
项目中遇到了慢查询问题 Sql语句 SELECT sum(price) AS price, `member_id` FROM `crm_upload` GROUP BY member_id ORDER ...
- mysql copy表或表数据常用的语句整理汇总
mysql copy表或表数据常用的语句整理汇总. 假如我们有以下这样一个表: id username password ----------------------------------- 1 a ...
- mysql批量进行optimize table操作
数据库运行一段时间后,有可能会有磁盘磁片产生,此时我们需要进行optimize table操作 # 获取需要optimize的表:如下为获取总大小小于80G的表进行操作:mysql -utroot - ...
- MySQL出现Waiting for table metadata lock的原因以及解决方法
转自:http://ctripmysqldba.iteye.com/blog/1938150 (有修改) MySQL在进行alter table等DDL操作时,有时会出现Waiting for tab ...
- 【转】【MySql】Waiting for table metadata lock原因分析
MySQL在进行alter table等DDL操作时,有时会出现Waiting for table metadata lock的等待场景.而且,一旦alter table TableA的操作停滞在Wa ...
- 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 ...
- 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 ...
随机推荐
- flask SQLAlchemy query.filter_by 常用操作符
常用的filter操作符 下面的这些操作符可以应用在filter函数中 equals: query.filter(User.name == 'ed') not equals: query.filter ...
- Struts2笔记1
一.简介 1.作用于web层:Struts2是一种基于MVC模式的轻量级Web框架; 2.各文件夹简介: apps:该文件夹存用于存放官方提供的Struts2示例程序,这些程序可以作为学习者 ...
- 返回mapcontrol上的已被选择的element
IGraphicsContainerSelect.SelectedElement
- nodejs请求中获取参数值的方法
req.params.xxxxx 从path中的变量 req.query.xxxxx 从get中的?xxxx=中 req.body.xxxxx 从post中的变量
- MySQL使用一张表的一列更新另一张表的一列
使用MySQL中,在一张表etl_table_field_info上新增了一个字段tgt_table_en_name,该字段的值想从表etl_table_property_info的tgt_table ...
- linux网卡的配置(解决刚刚安装linux,Xshell连接不上问题)
1.输入用户名和密码 2.cd到网卡文件夹 3.对网卡文件进行编辑 vi ifcfg-eth0 然后 a 进行编辑 然后esc退出,shift+zz保存 4.重启网卡 /etc/init.d/netw ...
- PC:各大主板开机启动项快捷键
组装机主板 品牌笔记本 品牌台式机 主板品牌 启动按键 笔记本品牌 启动按键 台式机品牌 启动按键 华硕主板 F8 联想笔记本 F12 联想台式机 F12 技嘉主板 F12 宏基笔记本 F12 惠普台 ...
- UVA 215 Spreadsheet Calculator (模拟)
模拟题.每个单元格有表达式就dfs,如果有环那么就不能解析,可能会重复访问到不能解析的单元格,丢set里或者数组判下重复. 这种题首先框架要对,变量名不要取的太乱,细节比较多,知道的库函数越多越容易写 ...
- hdu-2112 HDU Today---dijkstra+标号
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=2112. 题目大意: 求起点到终点的最短路 解题思路: 对地名进行编号即可 然后直接dijkstra算 ...
- python_45_目录编程
#获取当前目录 import os print(os.getcwd()) #获取目录内容 import os print(os.listdir('C:\\Python27')) #创建目录 impor ...