有时十几个连接,CPU也会跳到100%, 然后经过一会mysql就自动关闭了,不知道怎么回事
线程数有时候会跳到几关个,都不会自动断开了,求解

解决方案 »

  1.   

    数据10多万条, 下面这个语句执行时间9秒, 不知道为什么# Query_time: 9  Lock_time: 2  Rows_sent: 12  Rows_examined: 64841
    select id,title from so_subject where oneid=11 order by day_num desc limit 0,12;
    # User@Host: ggssw[ggssw] @ localhost [127.0.0.1]
    # Query_time: 9  Lock_time: 2  Rows_sent: 1  Rows_examined: 64830
    select id,title from so_subject where oneid=11 and id < 133842 order by id desc limit 0,1;
    # User@Host: ggssw[ggssw] @ localhost [127.0.0.1]
    # Query_time: 9  Lock_time: 2  Rows_sent: 1  Rows_examined: 64830
    select id,title from so_subject where oneid=11 and id < 85427 order by id desc limit 0,1;
    # User@Host: ggssw[ggssw] @ localhost [127.0.0.1]
    # Query_time: 7  Lock_time: 0  Rows_sent: 1  Rows_examined: 64830
    select id,title from so_subject where oneid=11 and id > 158043 order by id desc limit 0,1;
      

  2.   


    EXPLAIN select id,title from so_subject where oneid=11 order by day_num desc limit 0,12\G看下其执行计划.....是不是无索引可走,还是索引执行计划有问题...
      

  3.   

    1 oneid查下有没有建索引,另外ID是不是自增的主键。
    2 oneid看下是int的还是varchar的,如果是varchar改成int之类的类型,或者用oneid='11'
      

  4.   

    在CPU很高的时候,show full processlist看看是什么语句在跑,然后把这些查询优化,让它很快运行完毕。
      

  5.   

    打开慢查询explain优化一下,就没事了,,在有设置一下my.ini的参数
      

  6.   

    mysql down掉了。
    检查的步骤看一下binlog日志具体的操作。
    另外查看一下具体的进程show processlist