{"id":25899,"date":"2024-11-24T15:11:21","date_gmt":"2024-11-24T07:11:21","guid":{"rendered":"https:\/\/fwq.ai\/blog\/25899\/"},"modified":"2024-11-24T15:11:21","modified_gmt":"2024-11-24T07:11:21","slug":"%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8-mysql-%e7%bb%9f%e8%ae%a1%e6%af%8f%e4%b8%aa%e7%9b%91%e6%b5%8b%e5%af%b9%e8%b1%a1%e8%a7%a3%e6%9e%90%e5%a4%b1%e8%b4%a5%e7%8e%87%ef%bc%9f-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/25899\/","title":{"rendered":"\u5982\u4f55\u4f7f\u7528 MySQL \u7edf\u8ba1\u6bcf\u4e2a\u76d1\u6d4b\u5bf9\u8c61\u89e3\u6790\u5931\u8d25\u7387\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173072324158273.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u4f7f\u7528 MySQL \u7edf\u8ba1\u6bcf\u4e2a\u76d1\u6d4b\u5bf9\u8c61\u89e3\u6790\u5931\u8d25\u7387\uff1f\u63d2\u56fe\" alt=\"\u5982\u4f55\u4f7f\u7528 MySQL \u7edf\u8ba1\u6bcf\u4e2a\u76d1\u6d4b\u5bf9\u8c61\u89e3\u6790\u5931\u8d25\u7387\uff1f\u63d2\u56fe\" \/><\/p>\n<h2>  \u5206\u7ec4\u7edf\u8ba1\u89e3\u6790\u5931\u8d25\u7387<\/h2>\n<p><strong>\u95ee\u9898\u63cf\u8ff0<\/strong><\/p>\n<p>\u5047\u8bbe\u6709\u4e00\u4e2a\u540d\u4e3a parse_monitoring \u7684\u8868\uff0c\u5176\u4e2d\u5305\u542b\u89e3\u6790\u8fc7\u7a0b\u7684\u76d1\u6d4b\u4fe1\u606f\u3002\u8868\u4e2d\u5305\u62ec\u4ee5\u4e0b\u5b57\u6bb5\uff1a<\/p>\n<ul>\n<li>id\uff1a\u81ea\u589e\u4e3b\u952e<\/li>\n<li>track_source_id\uff1a\u76d1\u6d4b\u5bf9\u8c61\u7684 id<\/li>\n<li>is_parsed\uff1a\u89e3\u6790\u6210\u529f\u72b6\u6001\uff080 \u8868\u793a\u5931\u8d25\uff0c1 \u8868\u793a\u6210\u529f\uff09<\/li>\n<li>parsed_at\uff1a\u89e3\u6790\u65f6\u95f4<\/li>\n<\/ul>\n<p><strong>\u9700\u6c42<\/strong><\/p>\n<p>\u9700\u8981\u7edf\u8ba1\u6bcf\u4e2a track_source_id \u7684\u89e3\u6790\u5931\u8d25\u7387\u3002<\/p>\n<p><strong>\u89e3\u51b3\u65b9\u6848<\/strong><\/p>\n<p>\u8981\u7edf\u8ba1\u89e3\u6790\u5931\u8d25\u7387\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b sql \u67e5\u8be2\uff1a<\/p>\n<pre>SELECT track_source_id, 1 - SUM(is_parsed) \/ COUNT(*) AS failure_rate\nFROM parse_monitoring\nGROUP BY track_source_id<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u67e5\u8be2\u5256\u6790<\/strong><\/p>\n<ul>\n<li>group by track_source_id\uff1a\u5c06\u7ed3\u679c\u6309 track_source_id \u5206\u7ec4\uff0c\u5206\u522b\u8ba1\u7b97\u6bcf\u4e2a\u5206\u7ec4\u4e2d\u7684\u5931\u8d25\u7387\u3002<\/li>\n<li>sum(is_parsed) \/ count(*)\uff1a\u8ba1\u7b97\u6bcf\u4e2a\u5206\u7ec4\u4e2d\u89e3\u6790\u6210\u529f\u7684\u5360\u6bd4\uff0c\u518d\u7528 1 \u51cf\u53bb\u8be5\u5360\u6bd4\u5373\u53ef\u5f97\u5230\u5931\u8d25\u7387\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u4f7f\u7528 MySQL \u7edf\u8ba1\u6bcf\u4e2a\u76d1\u6d4b\u5bf9\u8c61\u89e3\u6790\u5931\u8d25\u7387\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5206\u7ec4\u7edf\u8ba1\u89e3\u6790\u5931\u8d25\u7387 \u95ee\u9898\u63cf\u8ff0 \u5047\u8bbe\u6709\u4e00\u4e2a\u540d\u4e3a parse_monitoring \u7684\u8868\uff0c\u5176\u4e2d\u5305\u542b\u89e3\u6790\u8fc7\u7a0b\u7684\u76d1\u6d4b\u4fe1\u606f\u3002\u8868\u4e2d\u5305\u62ec\u4ee5\u4e0b\u5b57\u6bb5\uff1a id\uff1a\u81ea\u589e\u4e3b\u952e track_source_id\uff1a\u76d1\u6d4b\u5bf9\u8c61\u7684 id is_parsed\uff1a\u89e3\u6790\u6210\u529f\u72b6\u6001\uff080 \u8868\u793a\u5931\u8d25\uff0c1 \u8868\u793a\u6210\u529f\uff09 parsed_at\uff1a\u89e3\u6790\u65f6\u95f4 \u9700\u6c42 \u9700\u8981\u7edf\u8ba1\u6bcf\u4e2a track_source_id \u7684\u89e3\u6790\u5931\u8d25\u7387\u3002 \u89e3\u51b3\u65b9\u6848 \u8981\u7edf\u8ba1\u89e3\u6790\u5931\u8d25\u7387\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b sql \u67e5\u8be2\uff1a SELECT track_source_id, 1 &#8211; SUM(is_parsed) \/ COUNT(*) AS failure_rate FROM parse_monitoring GROUP BY track_source_id \u767b\u5f55\u540e\u590d\u5236 \u67e5\u8be2\u5256\u6790 group by track_source_id\uff1a\u5c06\u7ed3\u679c\u6309 track_source_id \u5206\u7ec4\uff0c\u5206\u522b\u8ba1\u7b97\u6bcf\u4e2a\u5206\u7ec4\u4e2d\u7684\u5931\u8d25\u7387\u3002 sum(is_parsed) \/ count(*)\uff1a\u8ba1\u7b97\u6bcf\u4e2a\u5206\u7ec4\u4e2d\u89e3\u6790\u6210\u529f\u7684\u5360\u6bd4\uff0c\u518d\u7528 1 \u51cf\u53bb\u8be5\u5360\u6bd4\u5373\u53ef\u5f97\u5230\u5931\u8d25\u7387\u3002 \u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u4f7f\u7528 MySQL \u7edf\u8ba1\u6bcf\u4e2a\u76d1\u6d4b\u5bf9\u8c61\u89e3\u6790\u5931\u8d25\u7387\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-25899","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/25899","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=25899"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/25899\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=25899"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=25899"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=25899"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}