开发者社区> 问答> 正文

mysqld有时候占用CPU搞,请高手指导


MySQLa, Version: 5.5.40 (MySQL Community Server (GPL)). started with:
TCP Port: 6306, Named Pipe: /tmp/mysql.sock
Time                 Id Command    Argument
# Time: 151105 15:14:35
# User@Host: root[root] @ localhost [127.0.0.1]
# Query_time: 5.312602  Lock_time: 0.000000 Rows_sent: 1  Rows_examined: 185087
use ultrax;
SET timestamp=1446707675;
SELECT count(*) FROM pre_forum_thread where authorid='3' and displayorder!=-2 and displayorder!=-1;
# Time: 151105 15:14:37
# User@Host: root[root] @ localhost [127.0.0.1]
# Query_time: 5.750111  Lock_time: 0.000000 Rows_sent: 12  Rows_examined: 185111
SET timestamp=1446707677;
SELECT a.tid,a.subject,a.fid,b.name FROM pre_forum_thread a inner join pre_forum_forum b on a.fid=b.fid where a.authorid=3  and a.displayorder!=-2 and a.displayorder!=-1 order by a.dateline DESC LIMIT 0,12;
# Time: 151105 15:14:40
# User@Host: root[root] @ localhost [127.0.0.1]
# Query_time: 5.687609  Lock_time: 0.000000 Rows_sent: 12  Rows_examined: 185111
SET timestamp=1446707680;
SELECT a.tid,a.subject,a.fid,b.name FROM pre_forum_thread a inner join pre_forum_forum b on a.fid=b.fid where a.authorid=3  and a.displayorder!=-2 and a.displayorder!=-1 order by a.dateline DESC LIMIT 0,12;
# User@Host: root[root] @ localhost [127.0.0.1]
# Query_time: 5.296976  Lock_time: 0.000000 Rows_sent: 12  Rows_examined: 185111
SET timestamp=1446707680;
SELECT a.tid,a.subject,a.fid,b.name FROM pre_forum_thread a inner join pre_forum_forum b on a.fid=b.fid where a.authorid=3  and a.displayorder!=-2 and a.displayorder!=-1 order by a.dateline DESC LIMIT 0,12;
# Time: 151105 15:14:41
# User@Host: root[root] @ localhost [127.0.0.1]
# Query_time: 5.890738  Lock_time: 0.000000 Rows_sent: 12  Rows_examined: 185111
SET timestamp=1446707681;
SELECT a.tid,a.subject,a.fid,b.name FROM pre_forum_thread a inner join pre_forum_forum b on a.fid=b.fid where a.authorid=3  and a.displayorder!=-2 and a.displayorder!=-1 order by a.dateline DESC LIMIT 0,12;
# Time: 151105 15:14:42
# User@Host: root[root] @ localhost [127.0.0.1]
# Query_time: 6.609502  Lock_time: 0.000000 Rows_sent: 12  Rows_examined: 185111
SET timestamp=1446707682;
SELECT a.tid,a.subject,a.fid,b.name FROM pre_forum_thread a inner join pre_forum_forum b on a.fid=b.fid where a.authorid=3  and a.displayorder!=-2 and a.displayorder!=-1 order by a.dateline DESC LIMIT 0,12;
# Time: 151105 16:03:29
# User@Host: root[root] @ localhost [127.0.0.1]
# Query_time: 55.031954  Lock_time: 0.000000 Rows_sent: 10  Rows_examined: 743696
SET timestamp=1446710609;
select a.tid,a.subject,a.dateline,a.views,a.replies,a.author,a.authorid,b.message from pre_forum_thread a join pre_forum_post b on a.tid=b.tid where a.attachment!=0 and a.displayorder>=0 and b.first=1 order by tid desc limit 0,10;
# Time: 151105 16:04:18
# User@Host: root[root] @ localhost [127.0.0.1]
# Query_time: 46.578721  Lock_time: 0.000000 Rows_sent: 10  Rows_examined: 743698
SET timestamp=1446710658;
select a.tid,a.subject,a.dateline,a.views,a.replies,a.author,a.authorid,b.message from pre_forum_thread a join pre_forum_post b on a.tid=b.tid where a.attachment!=0 and a.displayorder>=0 and b.first=1 order by tid desc limit 0,10;
# Time: 151105 16:04:30
# User@Host: root[root] @ localhost [127.0.0.1]
# Query_time: 6.765712  Lock_time: 1.531270 Rows_sent: 12  Rows_examined: 185111
SET timestamp=1446710670;
SELECT a.tid,a.subject,a.fid,b.name FROM pre_forum_thread a inner join pre_forum_forum b on a.fid=b.fid where a.authorid=3  and a.displayorder!=-2 and a.displayorder!=-1 order by a.dateline DESC LIMIT 0,12;
# Time: 151105 16:04:46
# User@Host: root[root] @ localhost [127.0.0.1]
# Query_time: 7.078215  Lock_time: 0.000000 Rows_sent: 12  Rows_examined: 185111
SET timestamp=1446710686;
SELECT a.tid,a.subject,a.fid,b.name FROM pre_forum_thread a inner join pre_forum_forum b on a.fid=b.fid where a.authorid=3  and a.displayorder!=-2 and a.displayorder!=-1 order by a.dateline DESC LIMIT 0,12;
# Time: 151105 16:13:25
# User@Host: root[root] @ localhost [127.0.0.1]
# Query_time: 5.718823  Lock_time: 0.406255 Rows_sent: 12  Rows_examined: 185111
SET timestamp=1446711205;
SELECT a.tid,a.subject,a.fid,b.name FROM pre_forum_thread a inner join pre_forum_forum b on a.fid=b.fid where a.authorid=3  and a.displayorder!=-2 and a.displayorder!=-1 order by a.dateline DESC LIMIT 0,12;
# Time: 151105 16:13:52
# User@Host: root[root] @ localhost [127.0.0.1]
# Query_time: 6.546959  Lock_time: 1.296892 Rows_sent: 12  Rows_examined: 185111
SET timestamp=1446711232;
SELECT a.tid,a.subject,a.fid,b.name FROM pre_forum_thread a inner join pre_forum_forum b on a.fid=b.fid where a.authorid=3  and a.displayorder!=-2 and a.displayorder!=-1 order by a.dateline DESC LIMIT 0,12;
# Time: 151105 16:13:53
# User@Host: root[root] @ localhost [127.0.0.1]
# Query_time: 6.609459  Lock_time: 0.625008 Rows_sent: 12  Rows_examined: 185111
SET timestamp=1446711233;
SELECT a.tid,a.subject,a.fid,b.name FROM pre_forum_thread a inner join pre_forum_forum b on a.fid=b.fid where a.authorid=3  and a.displayorder!=-2 and a.displayorder!=-1 order by a.dateline DESC LIMIT 0,12;
# Time: 151105 16:14:30
# User@Host: root[root] @ localhost [127.0.0.1]
# Query_time: 5.687573  Lock_time: 0.656259 Rows_sent: 12  Rows_examined: 185111
SET timestamp=1446711270;
SELECT a.tid,a.subject,a.fid,b.name FROM pre_forum_thread a inner join pre_forum_forum b on a.fid=b.fid where a.authorid=3  and a.displayorder!=-2 and a.displayorder!=-1 order by a.dateline DESC LIMIT 0,12;




这是记录的超过5秒的慢查询语句,请高手指点


将哪个表的哪个字段设置索引,如何操作

展开
收起
kanghuaiqia 2015-11-05 16:44:03 9054 0
4 条回答
写回答
取消 提交回答
  • 论坛总版主
    回 9楼(kanghuaiqia) 的帖子
    先关闭插件看看,估计插件的问题
    2015-11-06 14:51:16
    赞同 展开评论 打赏
  • 解决方案工程师,负责为企业规划上云迁移方案和云上架构设计,在网站建设开发和云计算领域有多年经验,专注于Linux平台的系统维护以及应用部署。致力于以场景化的方式让云计算,用更加通俗易懂的方式让更多人体验云计算,让云端的计算更质朴的落地。
    回 5楼(kanghuaiqia) 的帖子
    目前网站访问量如何,ecs配置如何

    my.cnf 怎么写的

    -------------------------

    回 7楼(kanghuaiqia) 的帖子
    ecs 配置呢?

    -------------------------

    回 9楼(kanghuaiqia) 的帖子
    InnoDB 都关闭了,内存也那么大,还搞满。。

    我觉得程序的问题,有语句错误,导致重复查询或者写入数据库
    2015-11-05 20:22:36
    赞同 展开评论 打赏
  • Remysqld有时候占用CPU搞,请高手指导
    是的,是DZ程序

    经常是MYSQL锁死,表现为网页曼或者打不开

    -------------------------

    Remysqld有时候占用CPU搞,请高手指导
    一直在论坛等着大神回复,希望二楼的朋友能指导一下

    -------------------------

    回1楼sunfei的帖子
    ????

    -------------------------

    Remysqld有时候占用CPU搞,请高手指导
    没有人帮我,都太势力了

    -------------------------

    回8楼ivmmff的帖子
    ecs双核2g内存3m带宽

    -------------------------

    Re:回 9楼(kanghuaiqia) 的帖子
    引用第10楼ivmmff于2015-11-06 13:40发表的 回 9楼(kanghuaiqia) 的帖子 :
    InnoDB 都关闭了,内存也那么大,还搞满。。

    我觉得程序的问题,有语句错误,导致重复查询或者写入数据库 [url=http://bbs.aliyun.com/job.php?action=topost&tid=262286&pid=724821][/url]





    慢查询里面有几句可疑


    # Query_time: 55.031954  Lock_time: 0.000000 Rows_sent: 10  Rows_examined: 743696 SET timestamp=1446710609; select a.tid,a.subject,a.dateline,a.views,a.replies,a.author,a.authorid,b.message from pre_forum_thread a join pre_forum_post b on a.tid=b.tid where a.attachment!=0 and a.displayorder>=0 and b.first=1 order by tid desc limit 0,10; # Time: 151105 16:04:18 # User@Host: root[root] @ localhost [127.0.0.1] # Query_time: 46.578721  Lock_time: 0.000000 Rows_sent: 10  Rows_examined: 743698 SET timestamp=1446710658; select a.tid,a.subject,a.dateline,a.views,a.replies,a.author,a.authorid,b.message from pre_forum_thread a join pre_forum_post b on a.tid=b.tid where a.attachment!=0 and a.displayorder>=0 and b.first=1 order by tid desc limit 0,10;


    不知道是DISCUZ哪里调用的这两句,非常奇怪
    2015-11-05 19:00:13
    赞同 展开评论 打赏
  • PHP程序员,业余无线电爱好者,呼号:BH9BHT,自由职业!
    看着像是dz的程序,是吗?
    2015-11-05 18:59:04
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
RDS SQL Server CPU高使用率性能优化 立即下载
Android应用启动速度和内存优化实践 立即下载
Android应用-启动速度和内存优化实践 立即下载

相关实验场景

更多