{"id":532,"date":"2008-09-24T00:00:00","date_gmt":"2008-09-23T16:00:00","guid":{"rendered":"http:\/\/www.strongd.net\/?p=532"},"modified":"2011-07-15T09:15:24","modified_gmt":"2011-07-15T01:15:24","slug":"%e4%ba%94%e6%ac%be%e5%b8%b8%e7%94%a8mysql-slow-log%e5%88%86%e6%9e%90%e5%b7%a5%e5%85%b7%e7%9a%84%e6%af%94%e8%be%83","status":"publish","type":"post","link":"https:\/\/www.strongd.net\/?p=532","title":{"rendered":"\u4e94\u6b3e\u5e38\u7528mysql slow log\u5206\u6790\u5de5\u5177\u7684\u6bd4\u8f83"},"content":{"rendered":"<p><DIV><SPAN class=Apple-style-span style=\"WORD-SPACING: 0px; FONT: 13px Arial; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate; TEXT-ALIGN: left; orphans: 2; widows: 2; webkit-border-horizontal-spacing: 1px; webkit-border-vertical-spacing: 1px; webkit-text-decorations-in-effect: none; webkit-text-size-adjust: auto; webkit-text-stroke-width: 0\">mysql slow log \u662f\u7528\u6765\u8bb0\u5f55\u6267\u884c\u65f6\u95f4\u8f83\u957f(\u8d85\u8fc7long_query_time\u79d2)\u7684sql\u7684\u4e00\u79cd\u65e5\u5fd7\u5de5\u5177.<br \/>\n<DIV style=\"MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px\"><br \/>\n<H3 style=\"PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 1.2em; PADDING-BOTTOM: 0px; MARGIN: 0px 0px 0.5em; COLOR: black; LINE-HEIGHT: 1.5em; PADDING-TOP: 0px\">\u542f\u7528 slow log<BR><\/H3><br \/>\n<DIV style=\"MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px\">\u6709\u4e24\u79cd\u542f\u7528\u65b9\u5f0f:<\/DIV>1, \u5728my.cnf \u91cc \u901a\u8fc7 log-slow-queries[=file_name]<\/DIV><br \/>\n<DIV style=\"MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px\">2, \u5728mysqld\u8fdb\u7a0b\u542f\u52a8\u65f6,\u6307\u5b9a&#8211;log-slow-queries[=file_name]\u9009\u9879<\/DIV><br \/>\n<H3 style=\"PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 1.2em; PADDING-BOTTOM: 0px; MARGIN: 0px 0px 0.5em; COLOR: black; LINE-HEIGHT: 1.5em; PADDING-TOP: 0px\">\u6bd4\u8f83\u7684\u4e94\u6b3e\u5e38\u7528\u5de5\u5177<BR><\/H3>mysqldumpslow, mysqlsla, myprofi, mysql-explain-slow-log, mysqllogfilter<br \/>\n<DIV style=\"MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px\"><BR><br \/>\n<DIV style=\"MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px\"><SPAN style=\"FONT-WEIGHT: bold\">mysqldumpslow<\/SPAN>, mysql\u5b98\u65b9\u63d0\u4f9b\u7684\u6162\u67e5\u8be2\u65e5\u5fd7\u5206\u6790\u5de5\u5177. \u8f93\u51fa\u56fe\u8868\u5982\u4e0b:<\/DIV><br \/>\n<DIV style=\"MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px\"><br \/>\n<DIV id=vf-i style=\"PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 0px; MARGIN-BOTTOM: 0px; PADDING-BOTTOM: 1em; PADDING-TOP: 1em; TEXT-ALIGN: left\"><IMG style=\"BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WIDTH: 643px; HEIGHT: 269px; BORDER-RIGHT-WIDTH: 0px\" alt=\"\" src=\"http:\/\/docs.google.com\/File?id=dtbhrmv_480cb9vf8hq_b\"><\/DIV><\/DIV><br \/>\n<DIV style=\"MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px\">\u4e3b\u8981\u529f\u80fd\u662f,&nbsp;\u7edf\u8ba1\u4e0d\u540c\u6162sql\u7684<\/DIV><br \/>\n<DIV style=\"MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px\">\u51fa\u73b0\u6b21\u6570(Count),&nbsp;<\/DIV><br \/>\n<DIV style=\"MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px\">\u6267\u884c\u6700\u957f\u65f6\u95f4(Time),&nbsp;<\/DIV><br \/>\n<DIV style=\"MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px\">\u7d2f\u8ba1\u603b\u8017\u8d39\u65f6\u95f4(Time),&nbsp;<\/DIV><br \/>\n<DIV style=\"MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px\">\u7b49\u5f85\u9501\u7684\u65f6\u95f4(Lock),&nbsp;<\/DIV><br \/>\n<DIV style=\"MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px\">\u53d1\u9001\u7ed9\u5ba2\u6237\u7aef\u7684\u884c\u603b\u6570(Rows),&nbsp;<\/DIV><br \/>\n<DIV style=\"MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px\">\u626b\u63cf\u7684\u884c\u603b\u6570(Rows),&nbsp;<\/DIV><br \/>\n<DIV style=\"MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px\">\u7528\u6237\u4ee5\u53casql\u8bed\u53e5\u672c\u8eab(\u62bd\u8c61\u4e86\u4e00\u4e0b\u683c\u5f0f, \u6bd4\u5982 limit 1, 20 \u7528 limit N,N \u8868\u793a).<\/DIV><br \/>\n<DIV style=\"MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px\"><SPAN style=\"FONT-WEIGHT: bold\"><BR><\/SPAN><\/DIV><br \/>\n<DIV style=\"MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px\"><SPAN style=\"FONT-WEIGHT: bold\">mysqlsla<SPAN style=\"FONT-WEIGHT: normal\">, hackmysql.com\u63a8\u51fa\u7684\u4e00\u6b3e\u65e5\u5fd7\u5206\u6790\u5de5\u5177(\u8be5\u7f51\u7ad9\u8fd8\u7ef4\u62a4\u4e86 mysqlreport, mysqlidxchk \u7b49\u6bd4\u8f83\u5b9e\u7528\u7684mysql\u5de5\u5177)<\/SPAN><BR><\/SPAN><\/DIV><br \/>\n<DIV style=\"MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px\"><br \/>\n<DIV id=dt4b style=\"PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 0px; MARGIN-BOTTOM: 0px; PADDING-BOTTOM: 1em; PADDING-TOP: 1em; TEXT-ALIGN: left\"><IMG style=\"BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WIDTH: 642px; HEIGHT: 343px; BORDER-RIGHT-WIDTH: 0px\" alt=\"\" src=\"http:\/\/docs.google.com\/File?id=dtbhrmv_481fwd54r4n_b\"><\/DIV><\/DIV><br \/>\n<DIV style=\"MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px\">\u6574\u4f53\u6765\u8bf4, \u529f\u80fd\u975e\u5e38\u5f3a\u5927. \u6570\u636e\u62a5\u8868,\u975e\u5e38\u6709\u5229\u4e8e\u5206\u6790\u6162\u67e5\u8be2\u7684\u539f\u56e0, \u5305\u62ec\u6267\u884c\u9891\u7387, \u6570\u636e\u91cf, \u67e5\u8be2\u6d88\u8017\u7b49.<BR><\/DIV><br \/>\n<DIV style=\"MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px\"><BR><\/DIV><br \/>\n<DIV style=\"MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px\">\u683c\u5f0f\u8bf4\u660e\u5982\u4e0b:<\/DIV><br \/>\n<DIV style=\"MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px\">\u603b\u67e5\u8be2\u6b21\u6570 (queries total), \u53bb\u91cd\u540e\u7684sql\u6570\u91cf (unique)<\/DIV><br \/>\n<DIV style=\"MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px\">\u8f93\u51fa\u62a5\u8868\u7684\u5185\u5bb9\u6392\u5e8f(sorted by)<\/DIV><br \/>\n<DIV style=\"MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px\">\u6700\u91cd\u5927\u7684\u6162sql\u7edf\u8ba1\u4fe1\u606f, \u5305\u62ec \u5e73\u5747\u6267\u884c\u65f6\u95f4, \u7b49\u5f85\u9501\u65f6\u95f4, \u7ed3\u679c\u884c\u7684\u603b\u6570, \u626b\u63cf\u7684\u884c\u603b\u6570.<\/DIV><br \/>\n<DIV style=\"MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px\"><BR><\/DIV><br \/>\n<DIV style=\"MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px\">Count, sql\u7684\u6267\u884c\u6b21\u6570\u53ca\u5360\u603b\u7684slow log\u6570\u91cf\u7684\u767e\u5206\u6bd4.<\/DIV><br \/>\n<DIV style=\"MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px\">Time, \u6267\u884c\u65f6\u95f4, \u5305\u62ec\u603b\u65f6\u95f4, \u5e73\u5747\u65f6\u95f4, \u6700\u5c0f, \u6700\u5927\u65f6\u95f4, \u65f6\u95f4\u5360\u5230\u603b\u6162sql\u65f6\u95f4\u7684\u767e\u5206\u6bd4.<\/DIV><br \/>\n<DIV style=\"MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px\">95% of Time, \u53bb\u9664\u6700\u5feb\u548c\u6700\u6162\u7684sql, \u8986\u76d6\u7387\u536095%\u7684sql\u7684\u6267\u884c\u65f6\u95f4.<\/DIV><br \/>\n<DIV style=\"MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px\">Lock Time, \u7b49\u5f85\u9501\u7684\u65f6\u95f4.<\/DIV><br \/>\n<DIV style=\"MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px\">95% of Lock , 95%\u7684\u6162sql\u7b49\u5f85\u9501\u65f6\u95f4.<\/DIV><br \/>\n<DIV style=\"MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px\">Rows sent, \u7ed3\u679c\u884c\u7edf\u8ba1\u6570\u91cf, \u5305\u62ec\u5e73\u5747, \u6700\u5c0f, \u6700\u5927\u6570\u91cf.<BR>Rows examined, \u626b\u63cf\u7684\u884c\u6570\u91cf.<\/DIV><br \/>\n<DIV style=\"MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px\">Database, \u5c5e\u4e8e\u54ea\u4e2a\u6570\u636e\u5e93<\/DIV><br \/>\n<DIV style=\"MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px\">Users, \u54ea\u4e2a\u7528\u6237,IP, \u5360\u5230\u6240\u6709\u7528\u6237\u6267\u884c\u7684sql\u767e\u5206\u6bd4<\/DIV><br \/>\n<DIV style=\"MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px\"><BR><\/DIV><br \/>\n<DIV style=\"MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px\">Query abstract, \u62bd\u8c61\u540e\u7684sql\u8bed\u53e5<\/DIV><br \/>\n<DIV style=\"MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px\">Query sample, sql\u8bed\u53e5<\/DIV><br \/>\n<DIV style=\"MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px\"><BR><\/DIV><br \/>\n<DIV style=\"MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px\">\u9664\u4e86\u4ee5\u4e0a\u7684\u8f93\u51fa, \u5b98\u65b9\u8fd8\u63d0\u4f9b\u4e86\u5f88\u591a\u5b9a\u5236\u5316\u53c2\u6570, \u662f\u4e00\u6b3e\u4e0d\u53ef\u591a\u5f97\u7684\u597d\u5de5\u5177.<\/DIV><br \/>\n<DIV style=\"MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px\"><BR><\/DIV><br \/>\n<DIV style=\"MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px\"><SPAN style=\"FONT-WEIGHT: bold\">mysql-explain-slow-log<\/SPAN>, \u5fb7\u56fd\u4eba\u5199\u7684\u4e00\u4e2aperl\u811a\u672c.<BR><A style=\"COLOR: rgb(0,102,153); TEXT-DECORATION: underline\" href=\"http:\/\/www.willamowius.de\/mysql-tools.html\">http:\/\/www.willamowius.de\/mysql-tools.html<\/A><BR><BR><\/DIV><br \/>\n<DIV style=\"MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px\"><IMG style=\"BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WIDTH: 642px; HEIGHT: 188px; BORDER-RIGHT-WIDTH: 0px\" alt=\"\" src=\"http:\/\/docs.google.com\/File?id=dtbhrmv_482dbz73bc2_b\"><BR><\/DIV><br \/>\n<DIV style=\"MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px\"><br \/>\n<DIV id=zs8m style=\"PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 0px; MARGIN-BOTTOM: 0px; PADDING-BOTTOM: 1em; PADDING-TOP: 1em; TEXT-ALIGN: left\"><br \/>\n<DIV id=hkj8 style=\"PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 0px; MARGIN-BOTTOM: 0px; PADDING-BOTTOM: 1em; PADDING-TOP: 1em; TEXT-ALIGN: left\"><IMG style=\"BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WIDTH: 637px; HEIGHT: 184px; BORDER-RIGHT-WIDTH: 0px\" alt=\"\" src=\"http:\/\/docs.google.com\/File?id=dtbhrmv_4835rp8jbgx_b\"><\/DIV><br \/>\n<DIV id=hkj8 style=\"PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 0px; MARGIN-BOTTOM: 0px; PADDING-BOTTOM: 1em; PADDING-TOP: 1em; TEXT-ALIGN: left\">\u529f\u80fd\u4e0a\u6709\u70b9\u7455\u75b5, \u4e0d\u4ec5\u628a\u6240\u6709\u7684 slow log \u6253\u5370\u5230\u5c4f\u5e55\u4e0a, \u800c\u4e14\u7edf\u8ba1\u4e5f\u53ea\u6709\u6570\u91cf\u800c\u5df2. \u4e0d\u63a8\u8350\u4f7f\u7528.<\/DIV><br \/>\n<DIV id=hkj8 style=\"PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 0px; MARGIN-BOTTOM: 0px; PADDING-BOTTOM: 1em; PADDING-TOP: 1em; TEXT-ALIGN: left\"><SPAN style=\"FONT-WEIGHT: bold\">mysql-log-filter<\/SPAN>, google code\u4e0a\u627e\u5230\u7684\u4e00\u4e2a\u5206\u6790\u5de5\u5177.\u63d0\u4f9b\u4e86 python \u548c php \u4e24\u79cd\u53ef\u6267\u884c\u7684\u811a\u672c.<BR><A style=\"COLOR: rgb(0,102,153); TEXT-DECORATION: underline\" href=\"http:\/\/code.google.com\/p\/mysql-log-filter\/\">http:\/\/code.google.com\/p\/mysql-log-filter\/<\/A><\/DIV><br \/>\n<DIV id=hkj8 style=\"PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 0px; MARGIN-BOTTOM: 0px; PADDING-BOTTOM: 1em; PADDING-TOP: 1em; TEXT-ALIGN: left\"><IMG class=magplus title=\u70b9\u51fb\u67e5\u770b\u539f\u59cb\u5927\u5c0f\u56fe\u7247 style=\"BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WIDTH: 847px; CURSOR: url(http:\/\/www.javaeye.com\/images\/magplus.gif), pointer; HEIGHT: 263px; BORDER-RIGHT-WIDTH: 0px\" height=235 alt=\"\" src=\"http:\/\/docs.google.com\/File?id=dtbhrmv_484d77sswt8_b\" width=760><\/DIV><br \/>\n<DIV id=hkj8 style=\"PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 0px; MARGIN-BOTTOM: 0px; PADDING-BOTTOM: 1em; PADDING-TOP: 1em; TEXT-ALIGN: left\">\u529f\u80fd\u4e0a\u6bd4\u5b98\u65b9\u7684mysqldumpslow, \u591a\u4e86\u67e5\u8be2\u65f6\u95f4\u7684\u7edf\u8ba1\u4fe1\u606f(\u5e73\u5747,\u6700\u5927, \u7d2f\u8ba1), \u5176\u4ed6\u529f\u80fd\u90fd\u4e0e mysqldumpslow\u7c7b\u4f3c.<BR>\u7279\u8272\u529f\u80fd\u9664\u4e86\u7edf\u8ba1\u4fe1\u606f\u5916, \u8fd8\u9488\u5bf9\u8f93\u51fa\u5185\u5bb9\u505a\u4e86\u6392\u7248\u548c\u683c\u5f0f\u5316, \u4fdd\u8bc1\u6574\u4f53\u8f93\u51fa\u7684\u7b80\u6d01. \u559c\u6b22\u7b80\u6d01\u62a5\u8868\u7684\u670b\u53cb, \u63a8\u8350\u4f7f\u7528\u4e00\u4e0b.<\/DIV><br \/>\n<DIV id=hkj8 style=\"PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 0px; MARGIN-BOTTOM: 0px; PADDING-BOTTOM: 1em; PADDING-TOP: 1em; TEXT-ALIGN: left\"><SPAN style=\"FONT-WEIGHT: bold\">myprofi<\/SPAN>, \u7eafphp\u5199\u7684\u4e00\u4e2a\u5f00\u6e90\u5206\u6790\u5de5\u5177.\u9879\u76ee\u5728 sourceforge \u4e0a.<BR><A style=\"COLOR: rgb(0,102,153); TEXT-DECORATION: underline\" href=\"http:\/\/myprofi.sourceforge.net\/\">http:\/\/myprofi.sourceforge.net\/<\/A><BR><BR><IMG class=magplus title=\u70b9\u51fb\u67e5\u770b\u539f\u59cb\u5927\u5c0f\u56fe\u7247 style=\"BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WIDTH: 867px; CURSOR: url(http:\/\/www.javaeye.com\/images\/magplus.gif), pointer; HEIGHT: 236px; BORDER-RIGHT-WIDTH: 0px\" height=206 alt=\"\" src=\"http:\/\/docs.google.com\/File?id=dtbhrmv_485c5jzsbdw_b\" width=760><\/DIV><br \/>\n<DIV id=hkj8 style=\"PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 0px; MARGIN-BOTTOM: 0px; PADDING-BOTTOM: 1em; PADDING-TOP: 1em; TEXT-ALIGN: left\">\u529f\u80fd\u4e0a, \u5217\u51fa\u4e86\u603b\u7684\u6162\u67e5\u8be2\u6b21\u6570\u548c\u7c7b\u578b, \u53bb\u91cd\u540e\u7684sql\u8bed\u53e5, \u6267\u884c\u6b21\u6570\u53ca\u5176\u5360\u603b\u7684slow log\u6570\u91cf\u7684\u767e\u5206\u6bd4.<BR>\u4ece\u6574\u4f53\u8f93\u51fa\u6837\u5f0f\u6765\u770b, \u6bd4mysql-log-filter\u8fd8\u8981\u7b80\u6d01. \u7701\u53bb\u4e86\u5f88\u591a\u4e0d\u5fc5\u8981\u7684\u5185\u5bb9. \u5bf9\u4e8e\u53ea\u60f3\u770bsql\u8bed\u53e5\u53ca\u6267\u884c\u6b21\u6570\u7684\u7528\u6237\u6765\u8bf4, \u6bd4\u8f83\u63a8\u8350.<\/DIV><br \/>\n<DIV id=hkj8 style=\"PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 0px; MARGIN-BOTTOM: 0px; PADDING-BOTTOM: 1em; PADDING-TOP: 1em; TEXT-ALIGN: left\"><br \/>\n<H3 style=\"PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 1.2em; PADDING-BOTTOM: 0px; MARGIN: 0px 0px 0.5em; COLOR: black; LINE-HEIGHT: 1.5em; PADDING-TOP: 0px\">\u603b\u7ed3<BR><\/H3><br \/>\n<DIV style=\"MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px\"><br \/>\n<TABLE class=zeroBorder id=fiar style=\"BORDER-RIGHT: gray 1px dotted; BORDER-TOP: gray 1px dotted; FONT-SIZE: 1em; BORDER-LEFT: gray 1px dotted; BORDER-BOTTOM: gray 1px dotted\" cellSpacing=0 cellPadding=3 width=\"100%\" border=0><br \/>\n<TBODY><br \/>\n<TR style=\"TEXT-ALIGN: left\"><br \/>\n<TD style=\"BORDER-RIGHT: gray 1px dotted; PADDING-RIGHT: 5px; BORDER-TOP: gray 1px dotted; PADDING-LEFT: 5px; FONT-SIZE: 1em; PADDING-BOTTOM: 5px; BORDER-LEFT: gray 1px dotted; PADDING-TOP: 5px; BORDER-BOTTOM: gray 1px dotted\" width=\"20%\">\u5de5\u5177\/\u529f\u80fd<\/TD><br \/>\n<TD style=\"BORDER-RIGHT: gray 1px dotted; PADDING-RIGHT: 5px; BORDER-TOP: gray 1px dotted; PADDING-LEFT: 5px; FONT-SIZE: 1em; PADDING-BOTTOM: 5px; BORDER-LEFT: gray 1px dotted; PADDING-TOP: 5px; BORDER-BOTTOM: gray 1px dotted\" width=\"20%\">\u4e00\u822c\u7edf\u8ba1\u4fe1\u606f<\/TD><br \/>\n<TD style=\"BORDER-RIGHT: gray 1px dotted; PADDING-RIGHT: 5px; BORDER-TOP: gray 1px dotted; PADDING-LEFT: 5px; FONT-SIZE: 1em; PADDING-BOTTOM: 5px; BORDER-LEFT: gray 1px dotted; PADDING-TOP: 5px; BORDER-BOTTOM: gray 1px dotted\" width=\"20%\">\u9ad8\u7ea7\u7edf\u8ba1\u4fe1\u606f<\/TD><br \/>\n<TD style=\"BORDER-RIGHT: gray 1px dotted; PADDING-RIGHT: 5px; BORDER-TOP: gray 1px dotted; PADDING-LEFT: 5px; FONT-SIZE: 1em; PADDING-BOTTOM: 5px; BORDER-LEFT: gray 1px dotted; PADDING-TOP: 5px; BORDER-BOTTOM: gray 1px dotted\" width=\"20%\">\u811a\u672c<\/TD><br \/>\n<TD style=\"BORDER-RIGHT: gray 1px dotted; PADDING-RIGHT: 5px; BORDER-TOP: gray 1px dotted; PADDING-LEFT: 5px; FONT-SIZE: 1em; PADDING-BOTTOM: 5px; BORDER-LEFT: gray 1px dotted; PADDING-TOP: 5px; BORDER-BOTTOM: gray 1px dotted\" width=\"20%\">\u4f18\u52bf<\/TD><\/TR><br \/>\n<TR style=\"TEXT-ALIGN: left\"><br \/>\n<TD style=\"BORDER-RIGHT: gray 1px dotted; PADDING-RIGHT: 5px; BORDER-TOP: gray 1px dotted; PADDING-LEFT: 5px; FONT-SIZE: 1em; PADDING-BOTTOM: 5px; BORDER-LEFT: gray 1px dotted; PADDING-TOP: 5px; BORDER-BOTTOM: gray 1px dotted\" width=\"20%\">mysqldumpslow<\/TD><br \/>\n<TD style=\"BORDER-RIGHT: gray 1px dotted; PADDING-RIGHT: 5px; BORDER-TOP: gray 1px dotted; PADDING-LEFT: 5px; FONT-SIZE: 1em; PADDING-BOTTOM: 5px; BORDER-LEFT: gray 1px dotted; PADDING-TOP: 5px; BORDER-BOTTOM: gray 1px dotted\" width=\"20%\">\u652f\u6301<\/TD><br \/>\n<TD style=\"BORDER-RIGHT: gray 1px dotted; PADDING-RIGHT: 5px; BORDER-TOP: gray 1px dotted; PADDING-LEFT: 5px; FONT-SIZE: 1em; PADDING-BOTTOM: 5px; BORDER-LEFT: gray 1px dotted; PADDING-TOP: 5px; BORDER-BOTTOM: gray 1px dotted\" width=\"20%\">\u4e0d\u652f\u6301<\/TD><br \/>\n<TD style=\"BORDER-RIGHT: gray 1px dotted; PADDING-RIGHT: 5px; BORDER-TOP: gray 1px dotted; PADDING-LEFT: 5px; FONT-SIZE: 1em; PADDING-BOTTOM: 5px; BORDER-LEFT: gray 1px dotted; PADDING-TOP: 5px; BORDER-BOTTOM: gray 1px dotted\" width=\"20%\">perl<\/TD><br \/>\n<TD style=\"BORDER-RIGHT: gray 1px dotted; PADDING-RIGHT: 5px; BORDER-TOP: gray 1px dotted; PADDING-LEFT: 5px; FONT-SIZE: 1em; PADDING-BOTTOM: 5px; BORDER-LEFT: gray 1px dotted; PADDING-TOP: 5px; BORDER-BOTTOM: gray 1px dotted\" width=\"20%\">mysql\u5b98\u65b9\u81ea\u5e26<\/TD><\/TR><br \/>\n<TR style=\"TEXT-ALIGN: left\"><br \/>\n<TD style=\"BORDER-RIGHT: gray 1px dotted; PADDING-RIGHT: 5px; BORDER-TOP: gray 1px dotted; PADDING-LEFT: 5px; FONT-SIZE: 1em; PADDING-BOTTOM: 5px; BORDER-LEFT: gray 1px dotted; PADDING-TOP: 5px; BORDER-BOTTOM: gray 1px dotted\" width=\"20%\">mysqlsla<\/TD><br \/>\n<TD style=\"BORDER-RIGHT: gray 1px dotted; PADDING-RIGHT: 5px; BORDER-TOP: gray 1px dotted; PADDING-LEFT: 5px; FONT-SIZE: 1em; PADDING-BOTTOM: 5px; BORDER-LEFT: gray 1px dotted; PADDING-TOP: 5px; BORDER-BOTTOM: gray 1px dotted\" width=\"20%\">\u652f\u6301<\/TD><br \/>\n<TD style=\"BORDER-RIGHT: gray 1px dotted; PADDING-RIGHT: 5px; BORDER-TOP: gray 1px dotted; PADDING-LEFT: 5px; FONT-SIZE: 1em; PADDING-BOTTOM: 5px; BORDER-LEFT: gray 1px dotted; PADDING-TOP: 5px; BORDER-BOTTOM: gray 1px dotted\" width=\"20%\">\u652f\u6301<\/TD><br \/>\n<TD style=\"BORDER-RIGHT: gray 1px dotted; PADDING-RIGHT: 5px; BORDER-TOP: gray 1px dotted; PADDING-LEFT: 5px; FONT-SIZE: 1em; PADDING-BOTTOM: 5px; BORDER-LEFT: gray 1px dotted; PADDING-TOP: 5px; BORDER-BOTTOM: gray 1px dotted\" width=\"20%\">perl<\/TD><br \/>\n<TD style=\"BORDER-RIGHT: gray 1px dotted; PADDING-RIGHT: 5px; BORDER-TOP: gray 1px dotted; PADDING-LEFT: 5px; FONT-SIZE: 1em; PADDING-BOTTOM: 5px; BORDER-LEFT: gray 1px dotted; PADDING-TOP: 5px; BORDER-BOTTOM: gray 1px dotted\" width=\"20%\">\u529f\u80fd\u5f3a\u5927,\u6570\u636e\u62a5\u8868\u9f50\u5168,\u5b9a\u5236\u5316\u80fd\u529b\u5f3a.<\/TD><\/TR><br \/>\n<TR style=\"TEXT-ALIGN: left\"><br \/>\n<TD style=\"BORDER-RIGHT: gray 1px dotted; PADDING-RIGHT: 5px; BORDER-TOP: gray 1px dotted; PADDING-LEFT: 5px; FONT-SIZE: 1em; PADDING-BOTTOM: 5px; BORDER-LEFT: gray 1px dotted; PADDING-TOP: 5px; BORDER-BOTTOM: gray 1px dotted\" width=\"20%\">mysql-explain-slow-log<\/TD><br \/>\n<TD style=\"BORDER-RIGHT: gray 1px dotted; PADDING-RIGHT: 5px; BORDER-TOP: gray 1px dotted; PADDING-LEFT: 5px; FONT-SIZE: 1em; PADDING-BOTTOM: 5px; BORDER-LEFT: gray 1px dotted; PADDING-TOP: 5px; BORDER-BOTTOM: gray 1px dotted\" width=\"20%\">\u652f\u6301<\/TD><br \/>\n<TD style=\"BORDER-RIGHT: gray 1px dotted; PADDING-RIGHT: 5px; BORDER-TOP: gray 1px dotted; PADDING-LEFT: 5px; FONT-SIZE: 1em; PADDING-BOTTOM: 5px; BORDER-LEFT: gray 1px dotted; PADDING-TOP: 5px; BORDER-BOTTOM: gray 1px dotted\" width=\"20%\">\u4e0d\u652f\u6301<\/TD><br \/>\n<TD style=\"BORDER-RIGHT: gray 1px dotted; PADDING-RIGHT: 5px; BORDER-TOP: gray 1px dotted; PADDING-LEFT: 5px; FONT-SIZE: 1em; PADDING-BOTTOM: 5px; BORDER-LEFT: gray 1px dotted; PADDING-TOP: 5px; BORDER-BOTTOM: gray 1px dotted\" width=\"20%\">perl<\/TD><br \/>\n<TD style=\"BORDER-RIGHT: gray 1px dotted; PADDING-RIGHT: 5px; BORDER-TOP: gray 1px dotted; PADDING-LEFT: 5px; FONT-SIZE: 1em; PADDING-BOTTOM: 5px; BORDER-LEFT: gray 1px dotted; PADDING-TOP: 5px; BORDER-BOTTOM: gray 1px dotted\" width=\"20%\">\u65e0<\/TD><\/TR><br \/>\n<TR style=\"TEXT-ALIGN: left\"><br \/>\n<TD style=\"BORDER-RIGHT: gray 1px dotted; PADDING-RIGHT: 5px; BORDER-TOP: gray 1px dotted; PADDING-LEFT: 5px; FONT-SIZE: 1em; PADDING-BOTTOM: 5px; BORDER-LEFT: gray 1px dotted; PADDING-TOP: 5px; BORDER-BOTTOM: gray 1px dotted\" width=\"20%\">mysql-log-filter<\/TD><br \/>\n<TD style=\"BORDER-RIGHT: gray 1px dotted; PADDING-RIGHT: 5px; BORDER-TOP: gray 1px dotted; PADDING-LEFT: 5px; FONT-SIZE: 1em; PADDING-BOTTOM: 5px; BORDER-LEFT: gray 1px dotted; PADDING-TOP: 5px; BORDER-BOTTOM: gray 1px dotted\" width=\"20%\">\u652f\u6301<\/TD><br \/>\n<TD style=\"BORDER-RIGHT: gray 1px dotted; PADDING-RIGHT: 5px; BORDER-TOP: gray 1px dotted; PADDING-LEFT: 5px; FONT-SIZE: 1em; PADDING-BOTTOM: 5px; BORDER-LEFT: gray 1px dotted; PADDING-TOP: 5px; BORDER-BOTTOM: gray 1px dotted\" width=\"20%\">\u90e8\u5206\u652f\u6301<\/TD><br \/>\n<TD style=\"BORDER-RIGHT: gray 1px dotted; PADDING-RIGHT: 5px; BORDER-TOP: gray 1px dotted; PADDING-LEFT: 5px; FONT-SIZE: 1em; PADDING-BOTTOM: 5px; BORDER-LEFT: gray 1px dotted; PADDING-TOP: 5px; BORDER-BOTTOM: gray 1px dotted\" width=\"20%\">python or php<\/TD><br \/>\n<TD style=\"BORDER-RIGHT: gray 1px dotted; PADDING-RIGHT: 5px; BORDER-TOP: gray 1px dotted; PADDING-LEFT: 5px; FONT-SIZE: 1em; PADDING-BOTTOM: 5px; BORDER-LEFT: gray 1px dotted; PADDING-TOP: 5px; BORDER-BOTTOM: gray 1px dotted\" width=\"20%\">\u4e0d\u5931\u529f\u80fd\u7684\u524d\u63d0\u4e0b,\u4fdd\u6301\u8f93\u51fa\u7b80\u6d01<\/TD><\/TR><br \/>\n<TR style=\"TEXT-ALIGN: left\"><br \/>\n<TD style=\"BORDER-RIGHT: gray 1px dotted; PADDING-RIGHT: 5px; BORDER-TOP: gray 1px dotted; PADDING-LEFT: 5px; FONT-SIZE: 1em; PADDING-BOTTOM: 5px; BORDER-LEFT: gray 1px dotted; PADDING-TOP: 5px; BORDER-BOTTOM: gray 1px dotted\" width=\"20%\">myprofi<\/TD><br \/>\n<TD style=\"BORDER-RIGHT: gray 1px dotted; PADDING-RIGHT: 5px; BORDER-TOP: gray 1px dotted; PADDING-LEFT: 5px; FONT-SIZE: 1em; PADDING-BOTTOM: 5px; BORDER-LEFT: gray 1px dotted; PADDING-TOP: 5px; BORDER-BOTTOM: gray 1px dotted\" width=\"20%\">\u652f\u6301<\/TD><br \/>\n<TD style=\"BORDER-RIGHT: gray 1px dotted; PADDING-RIGHT: 5px; BORDER-TOP: gray 1px dotted; PADDING-LEFT: 5px; FONT-SIZE: 1em; PADDING-BOTTOM: 5px; BORDER-LEFT: gray 1px dotted; PADDING-TOP: 5px; BORDER-BOTTOM: gray 1px dotted\" width=\"20%\">\u4e0d\u652f\u6301<\/TD><br \/>\n<TD style=\"BORDER-RIGHT: gray 1px dotted; PADDING-RIGHT: 5px; BORDER-TOP: gray 1px dotted; PADDING-LEFT: 5px; FONT-SIZE: 1em; PADDING-BOTTOM: 5px; BORDER-LEFT: gray 1px dotted; PADDING-TOP: 5px; BORDER-BOTTOM: gray 1px dotted\" width=\"20%\">php<\/TD><br \/>\n<TD style=\"BORDER-RIGHT: gray 1px dotted; PADDING-RIGHT: 5px; BORDER-TOP: gray 1px dotted; PADDING-LEFT: 5px; FONT-SIZE: 1em; PADDING-BOTTOM: 5px; BORDER-LEFT: gray 1px dotted; PADDING-TOP: 5px; BORDER-BOTTOM: gray 1px dotted\" width=\"20%\">\u975e\u5e38\u7cbe\u7b80<\/TD><\/TR><\/TBODY><\/TABLE><\/DIV><\/DIV><\/DIV><\/DIV><\/DIV><\/SPAN><\/DIV><\/p>\n","protected":false},"excerpt":{"rendered":"<p>mysql slow log \u662f\u7528\u6765\u8bb0\u5f55\u6267\u884c\u65f6\u95f4\u8f83\u957f(\u8d85\u8fc7long_query_time\u79d2)\u7684sql\u7684\u4e00\u79cd\u65e5\u5fd7\u5de5\u5177. \u542f\u7528 slow log \u6709\u4e24\u79cd\u542f\u7528\u65b9\u5f0f:1, \u5728my.cnf \u91cc \u901a\u8fc7 log-slow-queries[=file_name] 2, \u5728mysqld\u8fdb\u7a0b\u542f\u52a8\u65f6,\u6307\u5b9a&#8211;log-slow-queries[=file_name]\u9009\u9879 \u6bd4\u8f83\u7684\u4e94\u6b3e\u5e38\u7528\u5de5\u5177mysqldumpslow, mysqlsla, myprofi, mysql-explain-slow-log, mysqllogfilter mysqldumpslow, mysql\u5b98\u65b9\u63d0\u4f9b\u7684\u6162\u67e5\u8be2\u65e5\u5fd7\u5206\u6790\u5de5\u5177. \u8f93\u51fa\u56fe\u8868\u5982\u4e0b: \u4e3b\u8981\u529f\u80fd\u662f,&nbsp;\u7edf\u8ba1\u4e0d\u540c\u6162sql\u7684 \u51fa\u73b0\u6b21\u6570(Count),&nbsp; \u6267\u884c\u6700\u957f\u65f6\u95f4(Time),&nbsp; \u7d2f\u8ba1\u603b\u8017\u8d39\u65f6\u95f4(Time),&nbsp; \u7b49\u5f85\u9501\u7684\u65f6\u95f4(Lock),&nbsp; \u53d1\u9001\u7ed9\u5ba2\u6237\u7aef\u7684\u884c\u603b\u6570(Rows),&nbsp; \u626b\u63cf\u7684\u884c\u603b\u6570(Rows),&nbsp; \u7528\u6237\u4ee5\u53casql\u8bed\u53e5\u672c\u8eab(\u62bd\u8c61\u4e86\u4e00\u4e0b\u683c\u5f0f, \u6bd4\u5982 limit 1, 20 \u7528 limit N,N \u8868\u793a). mysqlsla, hackmysql.com\u63a8\u51fa\u7684\u4e00\u6b3e\u65e5\u5fd7\u5206\u6790\u5de5\u5177(\u8be5\u7f51\u7ad9\u8fd8\u7ef4\u62a4\u4e86 mysqlreport, mysqlidxchk \u7b49\u6bd4\u8f83\u5b9e\u7528\u7684mysql\u5de5\u5177) \u6574\u4f53\u6765\u8bf4, \u529f\u80fd\u975e\u5e38\u5f3a\u5927. \u6570\u636e\u62a5\u8868,\u975e\u5e38\u6709\u5229\u4e8e\u5206\u6790\u6162\u67e5\u8be2\u7684\u539f\u56e0, \u5305\u62ec\u6267\u884c\u9891\u7387, \u6570\u636e\u91cf, \u67e5\u8be2\u6d88\u8017\u7b49. \u683c\u5f0f\u8bf4\u660e\u5982\u4e0b: \u603b\u67e5\u8be2\u6b21\u6570 (queries total), \u53bb\u91cd\u540e\u7684sql\u6570\u91cf (unique) &hellip; <a href=\"https:\/\/www.strongd.net\/?p=532\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">\u4e94\u6b3e\u5e38\u7528mysql slow log\u5206\u6790\u5de5\u5177\u7684\u6bd4\u8f83<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19],"tags":[203],"class_list":["post-532","post","type-post","status-publish","format-standard","hentry","category-mysql","tag-mysql"],"_links":{"self":[{"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/posts\/532","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.strongd.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=532"}],"version-history":[{"count":1,"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/posts\/532\/revisions"}],"predecessor-version":[{"id":837,"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/posts\/532\/revisions\/837"}],"wp:attachment":[{"href":"https:\/\/www.strongd.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=532"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.strongd.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=532"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.strongd.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=532"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}