Copying to tmp table 解决方式

来源:互联网 发布:win8 怎么安装ubuntu 编辑:程序博客网 时间:2024/05/29 15:03
解决一例最近常常碰到网站慢的情况,登陆到台,查询一下 /opt/mysql/bin/mysqladmin processlist;
发现一个查询状态为: Copying to tmp table 而且此查询速度非常慢,基本一分钟左右才出来,后面是很多查询,状态为lock。
分析对我没有太大的作用,因此用google查询了一下,发现网上一篇文章讲得很好: 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的限制,那么mysql用/tmp保存查询结果,然后返回给客户端。
set global tmp_table_size=209715200 (200M) 再次运行此查询,用/opt/mysql/bin/mysqladmin processlist;
进行观察,发现不会出现上述问题.
至此问题解决. 调节tmp_table_size 的时候发现另外一些参数
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会被装载到内存。那样会增加数据库访问速度
0 0
原创粉丝点击