资源预览内容
第1页 / 共8页
第2页 / 共8页
第3页 / 共8页
第4页 / 共8页
第5页 / 共8页
第6页 / 共8页
第7页 / 共8页
第8页 / 共8页
亲,该文档总共8页全部预览完了,如果喜欢就下载吧!
资源描述
Slow LogSlow log大多都是order by引起的,explain语句有Using where; Using temporary; Using filesort的信息,有这个情况就会效率低了。解决这个的关键要在order by的字段上做索引。请看下面的例子:Report for slow logs: /data/3306/slow-log.log.16.26k queries total, 135 uniqueSorted by t_sumGrand Totals: Time 34.11k s, Lock 0 s, Rows sent 57.67k, Rows Examined 3.84M_ 001 _Count : 2.17k (34.64%)Time : 11031 s total, 5.090448 s avg, 3 s to 18 s max (32.34%) 95% of Time : 9605 s total, 4.667153 s avg, 3 s to 11 s maxLock Time (s) : 0 total, 0 avg, 0 to 0 max (0.00%) 95% of Lock : 0 total, 0 avg, 0 to 0 maxRows sent : 10 avg, 0 to 10 max (36.35%)Rows examined : 20 avg, 0 to 37 max (1.11%)Database : docresourceUsers : drhd 192.168.1.18 : 100.00% (2167) of query, 100.00% (6256) of all usersQuery abstract:SELECT t.cor_id,t.doc_title_upper,t.cor_doc_title,t.cor_doc_order,t.cor_doc_description,t.cor_doc_state FROM t_wiki_cordoc t WHERE t.cor_doc_state=N AND t.doc_title_upper=S ORDER BY t.cor_doc_order ASC LIMIT N;Query sample:SELECT T.COR_ID,T.DOC_TITLE_UPPER,T.COR_DOC_TITLE,T.COR_DOC_ORDER,T.COR_DOC_DESCRIPTION,T.COR_DOC_STATE FROM t_wiki_cordoc T where T.COR_DOC_STATE=1 and T.DOC_TITLE_UPPER=铔嬪僵鐢? ORDER BY T.COR_DOC_ORDER ASC LIMIT 10;解决方案:用java在内存排序。_ 002 _Count : 911 (14.56%)Time : 5342 s total, 5.863886 s avg, 3 s to 63 s max (15.66%) 95% of Time : 4381 s total, 5.06474 s avg, 3 s to 14 s maxLock Time (s) : 0 total, 0 avg, 0 to 0 max (0.00%) 95% of Lock : 0 total, 0 avg, 0 to 0 maxRows sent : 9 avg, 1 to 10 max (14.53%)Rows examined : 759 avg, 20 to 13.61k max (17.99%)Database : docresourceUsers : drhd 192.168.1.18 : 100.00% (911) of query, 100.00% (6256) of all usersQuery abstract:SELECT doc_id,doc_class,doc_title,doc_creator_user_id,doc_creator_user_nick,doc_latest_edition,doc_latest_url,doc_created_time,doc_latest_edition_time,doc_inner_pic_count,doc_outer_pic_count,doc_keywords,doc_click_count,doc_his_count,doc_attendee_count,doc_summary,doc_state,doc_goodcount,doc_badcount,doc_first_img,doc_title_upper,doc_import_tag,doc_topic_count,doc_post_count,doc_creator_user_id_encrypt,doc_id_encrypt,doc_score,last_edit_user_id_en,champion_user_nick,champion_user_id_en,champion_credit FROM t_wiki_doc WHERE doc_state IN (N4) AND doc_creator_user_id_encrypt=S ORDER BY doc_latest_edition_time DESC LIMIT N,N;Query sample:select doc_id,doc_class,doc_title,doc_creator_user_id,doc_creator_user_nick,doc_latest_edition,doc_latest_url,doc_created_time,doc_latest_edition_time,doc_inner_pic_count,doc_outer_pic_count,doc_keywords,doc_click_count,doc_his_count,doc_attendee_count,doc_summary,doc_state,doc_goodcount,doc_badcount,doc_first_img,doc_title_upper,doc_import_tag,doc_topic_count,doc_post_count,doc_creator_user_id_encrypt,doc_id_encrypt,doc_score,last_edit_user_id_en,champion_user_nick,champion_user_id_en,champion_credit from t_wiki_doc where doc_state in (1,2,3,4) and doc_creator_user_id_encrypt=tAQREAwRXWkJBUAoL order by DOC_LATEST_EDITION_TIME DESC limit 0,10;解决方案:alter table t_wiki_doc add index idx_create_user_iden_edittime(doc_creator_user_id_encrypt, doc_latest_edition_time);_ 003 _Count : 1.00k (16.06%)Time : 5114 s total, 5.088557 s avg, 3 s to 17 s max (14.99%) 95% of Time : 4426 s total, 4.639413 s avg, 3 s to 10 s maxLock Time (s) : 0 total, 0 avg, 0 to 0 max (0.00%) 95% of Lock : 0 total, 0 avg, 0 to 0 maxRows sent : 10 avg, 8 to 10 max (17.28%)Rows examined : 10 avg, 8 to 10 max (0.26%)Database : docresourceUsers : drhd 192.168.1.18 : 100.00% (1005) of query, 100.00% (6256) of all usersQuery abstract:SELECT doc_id,doc_class,doc_title,doc_creator_user_id,doc_creator_user_nick,doc_latest_edition,doc_latest_url,doc_created_time,doc_latest_edition_time,doc_inner_pic_count,doc_outer_pic_count,doc_keywords,doc_click_count,doc_his_count,doc_attendee_count,doc_summary,doc_state,doc_goodcount,doc_badcount,doc_first_img,doc_title_upper,doc_import_tag,doc_topic_count,doc_post_count,doc_creator_user_id_encrypt,doc_id_encrypt,doc_score,last_edit_user_id_en,champion_user_nick,champion_user_id_en,champion_credit FROM t_wiki_doc WHERE doc_title_upper IN (S10);Query sample:select doc_id,doc_class,doc_title,doc_creator_user_id,doc_creator_user_nick,doc_latest_edition,doc_latest_url,doc_created_time,doc_latest_edition_time,doc_inner_pic_count,doc_outer_pic_count,doc_keywords,doc_click_count,doc_his_count,doc_attendee_count,doc_summary,doc_state,doc_goodcount,doc_badcount,doc_first_img,doc_title_upper,doc_import_tag,doc_topic_count,doc_post_count,doc_creator_user_id_encrypt,doc_id_encrypt,doc_score,last_edit_user_id_en,cham
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号