技术开发 频道

mysql特定时间运行速度变慢的问题一例

【IT168 技术文档】  今天开始处理我们的后台数据库中的一个mysql的问题,问题症状是,每天有个不固定的时间,整个系统的sql执行会非常慢,如果你不理他,过会就自己好了。

  简单分析了下,那个系统就两个表,被设计成了mysql cluster模式。

  在slow log中有如下内容: 

1 ………
2
3 Count: 3568  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), session[session]@localhost
4 # Query_time: N.N  Lock_time: N.N Rows_sent: N  Rows_examined: N
5 SET timestamp=N;
6 select * from session where sky_id=N
7 Count: 284  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), session[session]@localhost
8 # Query_time: N.N  Lock_time: N.N Rows_sent: N  Rows_examined: N
9 SET timestamp=N;
10 delete from session where sky_id=N
11 Count: 690  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), session[session]@localhost
12 # Query_time: N.N  Lock_time: N.N Rows_sent: N  Rows_examined: N
13 SET timestamp=N;
14 insert into session(sky_id, user_name, nick_name, nick_name1, gender, age, portrait_id, token, province, city, pos_code, pos_desc, acc_esbaddr, acc_session_index, acc_type, ip, alive_check, rand_tag, last_oltime, logintime) values(N, ‘S’, ‘S’, ‘S’, N, N, N, N, ‘S’, ‘S’, N, ‘S’, N, N, N, ‘S’, N, N, N, N)
15 Count: 1572  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), session[session]@localhost
16 # Query_time: N.N  Lock_time: N.N Rows_sent: N  Rows_examined: N
17 SET timestamp=N;
18 select * from session where sky_id in (N,N)
19 Count: 3568  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), session[session]@localhost  # Query_time: N.N  Lock_time: N.N Rows_sent: N  Rows_examined: N  SET timestamp=N;  select * from session where sky_id=N
20 Count: 284  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), session[session]@localhost  # Query_time: N.N  Lock_time: N.N Rows_sent: N  Rows_examined: N  SET timestamp=N;  delete from session where sky_id=N
21 Count: 690  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), session[session]@localhost  # Query_time: N.N  Lock_time: N.N Rows_sent: N  Rows_examined: N  SET timestamp=N;  insert into session(sky_id, user_name, nick_name, nick_name1, gender, age, portrait_id, token, province, city, pos_code, pos_desc, acc_esbaddr, acc_session_index, acc_type, ip, alive_check, rand_tag, last_oltime, logintime) values(N, ‘S’, ‘S’, ‘S’, N, N, N, N, ‘S’, ‘S’, N, ‘S’, N, N, N, ‘S’, N, N, N, N)
22 Count: 1572  Time=0.00s (0s)  Lock=0.00s (0s)  Rows=0.0 (0), session[session]@localhost  # Query_time: N.N  Lock_time: N.N Rows_sent: N  Rows_examined: N  SET timestamp=N;  select * from session where sky_id in (N,N)
23
24 ………………..

 这段代码看,执行慢最多的sql居然是在session表上的,

0
相关文章