Mysql慢查询之Copying to tmp table
来源:互联网 发布:360数据恢复下载 编辑:程序博客网 时间:2024/05/29 08:38
问题:网站出现卡的情况,观察堆栈发现很多Copying to tmp table这种状态耗时较长
产生原因:Copying to tmp table on disk The temporary result set was larger than tmp_table_size and the thread is now changing the in memory-based temporary table to a disk based one to save memory。(如果查询超出了tmp_table_size的限制,那么用/tmp保存查询结果,tmp_table不得不拷到硬盘上,然后返回给客户端)
解决方案:放大tmp_table_size
1)查询tmp_table_size 为默认16M
mysql> show variables like '%tmp%';
+-------------------+----------+
| Variable_name | Value |
+-------------------+----------+
| max_tmp_tables | 32 |
| slave_load_tmpdir | /tmp |
| tmp_table_size | 16777216 |
| tmpdir | /tmp |
+-------------------+----------+
4 rows in set (0.00 sec)
/etc/my.cnf添加
tmp_table_size = 256M
2)优化sql
3)拓展-其他常用参数
mysql> show global status like ‘qcache%‘;
Qcache_queries_in_cache 在缓存中已注册的查询数目
Qcache_inserts 被加入到缓存中的查询数目
Qcache_hits 缓存采样数数目
Qcache_lowmem_prunes 因为缺少内存而被从缓存中删除的查询数目
Qcache_not_cached 没有被缓存的查询数目 (不能被缓存的,或由于 QUERY_CACHE_TYPE)
Qcache_free_memory 查询缓存的空闲内存总数
Qcache_free_blocks 查询缓存中的空闲内存块的数目
Qcache_total_blocks 查询缓存中的块的总数目
Qcache_free_memory 可以缓存一些常用的查询,如果是常用的sql会被装载到内存。那样会增加数据库访问速度
- Mysql慢查询之Copying to tmp table
- Mysql慢查询之Copying to tmp table
- mysql慢查询问题(Copying to tmp table)
- Mysql之Copying to tmp table
- mysql查询缓慢SQL State:Copying to tmp table
- Mysql中copying to tmp table事件的相关处理
- Copying to tmp table on disk
- Copying to tmp table 解决方式
- mysql Copying to tmp table on disk 影响性能的解决方法
- MySql操作缓慢:copy to tmp table
- MySql之慢查询
- mysql优化之慢查询
- MySQL之慢查询-删除慢查询日志
- MySQL之慢查询-删除慢查询日志
- MySQL之慢查询-删除慢查询日志
- mysql的"Incorrect key file for table '/tmp/#sql_1194_12.MYI'; try to repair it"问题
- Mysql大表数据局未加索引前存在Coping to tmp table耗时比较严重解决方法
- MySQL异常:Incorrect key file for table '/tmp/#sql_37b_1.MYI'; try to repair it
- 数论知识汇总(持续更新中)
- linux 代码段,数据段,堆,栈的存放
- iOS中UITextField 使用全面解析
- SharePoint 2013 Task Event : Create SubTask when new a master task
- Big Event in HDU 多重背包~
- Mysql慢查询之Copying to tmp table
- nginx配置中几个宏定义的解释
- Struts2 实现文件下载
- 修改lua_tinker以支持lua5.2
- POJ 2056
- windows套接字I/O模型之——阻塞模型(1)
- HDU1016-素数环
- java--加强之 Java5的线程并发库
- Linux下Eclipse的奇怪的问题