开发者

MySQL query stuck in a queue become a bottleneck

Recently, sometimes I cannot open my site.

I'm using VPS for hosting.

and when I do mytop

it shows me:

       User         Host/IP         DB      Time    Cmd Query or State                                                                                                                             
      --      ----         -------         --      ----    --- ----------                                                                                   
   12512   xxx       localhost xxx        39  Query SELECT * FROM user WHERE no = '12341'                                                                                                      
   12513   xxx       localhost xxx        39  Query SELECT name FROM user WHERE no = '2488'                                                                                                    
   12511   xxx       localhost xxx        40  Query UPDATE `user` SET `exp` = exp+6, `vright` = vright+1, `correct` = correct+1 WHERE `name` = 'Amethys'                                  开发者_JAVA百科     
   12465   xxx       localhost xxx        48  Query SELECT * FROM user WHERE name = 'pinoysamurai'                                                                                             
   12483   xxx       localhost xxx        48  Query SELECT * FROM user WHERE name = 'pinoysamurai'                                                                                             
   12501   xxx       localhost xxx        52  Query UPDATE `user` SET `exp` = exp+7, `vright` = vright+1, `correct` = correct+1 WHERE `name` = 'yuya_sama'                                     
   12422   xxx       localhost xxx        57  Query SELECT uo.name, ( SELECT COUNT(*) FROM user ui WHERE (ui.kright, ui.no) >= (uo.kright, uo.no) ) AS rank FROM user uo WHERE name = 0  

the most bottom query took more than 100 seconds to complete. and before it is completed, the queue behind it got stuck as well. You can see it on the mytop output.

what is the problem of this? I am so depressed...

I'm using itk mpm and here is my my.cnf file: (I have 512-1GB of RAM

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
old_passwords=1
interactive_timeout=27
wait_timeout=10
connect_timeout=10
skip-locking
skip-innodb
skip-bdb
max_connections=77
table_cache=2M
thread_cache_size=2M
query_cache_type=1
query_cache_limit=1M
query_cache_size=64M
key_buffer_size=64M
read_rnd_buffer_size=2M
read_buffer_size=2M
sort_buffer_size=2M
join_buffer_size=2M
thread_cache_size=128
thread_concurrency=12
thread_stack =256K
tmp_table_size=32M

Thank You,


Maybe it helps adding a combined index on kright, no so the join is faster? But I am not sure if MySQL would honour that.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜