我用的bo-blog,刚才,发现博客的服务器的负载很高,就一博客,不致与:
Top一看:
Mysql:
如下:
一看索引没有,赶紧加上索引:
SELECT `blogid`,`pubtime`,`edittime`,`blogalias` FROM `boblog_blogs` WHERE `property`<2 ORDER BY
alter table `boblog_blogs` add index property(property);
SELECT `blogid`,`title`,`blogalias` FROM `boblog_blogs` WHERE `property`<'2' AND `pubtime`<'13040783';
alter table `boblog_blogs` add index property_pubtime(property,pubtime);
SELECT * FROM `boblog_blogs` WHERE `property`<2 AND `frontpage`=0 ORDER BY `sticky`DESC, `pubtime`;
alter table `boblog_blogs` add index property_frontpage(property,frontpage);
博客次数和上面是一个表,索引加多了,update效率会不会下降?如下:
UPDATE LOW_PRIORITY `boblog_blogs` SET `views`=`views`+1 WHERE `blogid`='4257'
看来一个博客的访问设计仍旧需要考究和研究,我的博文也就3000多,DB性能就显现出来了。
后记:
查看后依旧有这样那样的小问题,但sleep和锁表大为缓解。
后来,负载降低,由25降低到5,说明还是有点效果滴嘛:
+----+-------------+--------------+-------+----------------------------------------------+----------+---------+------+------+-----------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+--------------+-------+----------------------------------------------+----------+---------+------+------+-----------------------------+
| 1 | SIMPLE | boblog_blogs | range | property,property_pubtime,property_frontpage | property | 4 | NULL | 3526 | Using where; Using filesort |
+----+-------------+--------------+-------+----------------------------------------------+----------+---------+------+------+-----------------------------+
Top一看:
Mysql:
如下:
一看索引没有,赶紧加上索引:
SELECT `blogid`,`pubtime`,`edittime`,`blogalias` FROM `boblog_blogs` WHERE `property`<2 ORDER BY
alter table `boblog_blogs` add index property(property);
SELECT `blogid`,`title`,`blogalias` FROM `boblog_blogs` WHERE `property`<'2' AND `pubtime`<'13040783';
alter table `boblog_blogs` add index property_pubtime(property,pubtime);
SELECT * FROM `boblog_blogs` WHERE `property`<2 AND `frontpage`=0 ORDER BY `sticky`DESC, `pubtime`;
alter table `boblog_blogs` add index property_frontpage(property,frontpage);
博客次数和上面是一个表,索引加多了,update效率会不会下降?如下:
UPDATE LOW_PRIORITY `boblog_blogs` SET `views`=`views`+1 WHERE `blogid`='4257'
看来一个博客的访问设计仍旧需要考究和研究,我的博文也就3000多,DB性能就显现出来了。
后记:
查看后依旧有这样那样的小问题,但sleep和锁表大为缓解。
后来,负载降低,由25降低到5,说明还是有点效果滴嘛:
+----+-------------+--------------+-------+----------------------------------------------+----------+---------+------+------+-----------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+--------------+-------+----------------------------------------------+----------+---------+------+------+-----------------------------+
| 1 | SIMPLE | boblog_blogs | range | property,property_pubtime,property_frontpage | property | 4 | NULL | 3526 | Using where; Using filesort |
+----+-------------+--------------+-------+----------------------------------------------+----------+---------+------+------+-----------------------------+
作者:jackxiang@向东博客 专注WEB应用 构架之美 --- 构架之美,在于尽态极妍 | 应用之美,在于药到病除
地址:https://jackxiang.com/post/4280/
版权所有。转载时必须以链接形式注明作者和原始出处及本声明!
最后编辑: jackxiang 编辑于2011-5-18 21:37
评论列表