Copying to tmp table Problem Solving
Labels: MySQL, MySQL_Problem_Solving
今天一早突然系統(tǒng)突然報(bào)慢,查了一下是以下語(yǔ)句:
| 6177700 username ip db——name Query 549 Copying to tmp table SELECT .................... |
原因如下:
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保存查詢結(jié)果,然后返回給客戶端。
set global tmp_table_size=209715200 (200M)
解決方法:
0. /opt/mysql/bin/mysqladmin processlist -uroot -ppassword --或者
mysql> set names utf8;
mysql> show processlist;
1. kill 6177700 --基本可以解決,如果殺不掉,運(yùn)行2,徹底點(diǎn)兒
2. sudo /etc/init.d/mysql restart
后續(xù):
1. explain看看select語(yǔ)句索引使用狀況:
| explain SELECT ............. |
2. 盡量避免用 not in ,in, left join ,right join用 exist ,not exist, minus等代替in ,not in
3.從網(wǎng)上查到,還要再看看更多參數(shù):
調(diào)節(jié)tmp_table_size 的時(shí)候發(fā)現(xiàn)另外一些參數(shù)
Qcache_queries_in_cache 在緩存中已注冊(cè)的查詢數(shù)目
Qcache_inserts 被加入到緩存中的查詢數(shù)目
Qcache_hits 緩存采樣數(shù)數(shù)目
Qcache_lowmem_prunes 因?yàn)槿鄙賰?nèi)存而被從緩存中刪除的查詢數(shù)目
Qcache_not_cached 沒(méi)有被緩存的查詢數(shù)目 (不能被緩存的,或由于 QUERY_CACHE_TYPE)
Qcache_free_memory 查詢緩存的空閑內(nèi)存總數(shù)
Qcache_free_blocks 查詢緩存中的空閑內(nèi)存塊的數(shù)目
Qcache_total_blocks 查詢緩存中的塊的總數(shù)目
Qcache_free_memory 可以緩存一些常用的查詢,如果是常用的sql會(huì)被裝載到內(nèi)存。那樣會(huì)增加數(shù)據(jù)庫(kù)訪問(wèn)速度。
轉(zhuǎn)載于:https://www.cnblogs.com/buro79xxd/archive/2009/11/24/1682569.html
總結(jié)
以上是生活随笔為你收集整理的Copying to tmp table Problem Solving的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: javascript保留两位
- 下一篇: win10蓝牙开关不见了_来自德国,比J