{"id":5258,"date":"2024-11-14T12:19:01","date_gmt":"2024-11-14T04:19:01","guid":{"rendered":"https:\/\/fwq.ai\/blog\/5258\/"},"modified":"2024-11-14T12:19:01","modified_gmt":"2024-11-14T04:19:01","slug":"mysql%e6%89%a7%e8%a1%8c%e8%ae%a1%e5%88%92%e6%80%8e%e4%b9%88%e5%86%99","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/5258\/","title":{"rendered":"mysql\u6267\u884c\u8ba1\u5212\u600e\u4e48\u5199"},"content":{"rendered":"<p><strong>\u5982\u4f55\u64b0\u5199  \u6267\u884c\u8ba1\u5212<\/strong><\/p>\n<p>MySQL \u6267\u884c\u8ba1\u5212\u662f\u4f18\u5316\u67e5\u8be2\u6027\u80fd\u7684\u5173\u952e\u5de5\u5177\uff0c\u5b83\u6982\u8ff0\u4e86 MySQL \u5904\u7406\u67e5\u8be2\u7684\u6b65\u9aa4\u3002\u672c\u6307\u5357\u5c06\u5411\u60a8\u5c55\u793a\u5982\u4f55\u521b\u5efa\u548c\u89e3\u91ca MySQL \u6267\u884c\u8ba1\u5212\u3002<\/p>\n<p><strong>\u5982\u4f55\u521b\u5efa\u6267\u884c\u8ba1\u5212<\/strong><\/p>\n<p>\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u751f\u6210\u6267\u884c\u8ba1\u5212\uff1a<\/p>\n<pre>EXPLAIN [FORMAT = {JSON | TREE | TRADITIONAL}] &lt;\u67e5\u8be2&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ul>\n<li> <strong>FORMAT=JSON<\/strong>\uff1a\u4ee5 JSON \u683c\u5f0f\u8f93\u51fa\u8ba1\u5212\u3002<\/li>\n<li> <strong>FORMAT=TREE<\/strong>\uff1a\u4ee5\u6811\u5f62\u7ed3\u6784\u8f93\u51fa\u8ba1\u5212\u3002<\/li>\n<li> <strong>FORMAT=TRADITIONAL<\/strong>\uff1a\u4ee5\u4f20\u7edf\u6587\u672c\u683c\u5f0f\u8f93\u51fa\u8ba1\u5212\u3002<\/li>\n<\/ul>\n<p><strong>\u6267\u884c\u8ba1\u5212\u7684\u7ed3\u6784<\/strong><\/p>\n<p>\u6267\u884c\u8ba1\u5212\u7531\u4ee5\u4e0b\u90e8\u5206\u7ec4\u6210\uff1a<\/p>\n<ul>\n<li> <strong>id<\/strong>\uff1a\u67e5\u8be2\u5757\u7684\u552f\u4e00\u6807\u8bc6\u7b26\u3002<\/li>\n<li> <strong>select_type<\/strong>\uff1a\u5757\u7684\u7c7b\u578b\uff0c\u4f8b\u5982 PRIMARY\u3001SUBQUERY\u3002<\/li>\n<li> <strong>table<\/strong>\uff1a\u5757\u4e2d\u6d89\u53ca\u7684\u8868\u3002<\/li>\n<li> <strong>type<\/strong>\uff1a\u5757\u7684\u7c7b\u578b\uff0c\u4f8b\u5982 ALL\u3001INDEX\u3001RANGE\u3002<\/li>\n<li> <strong>possible_keys<\/strong>\uff1a\u67e5\u8be2\u4e2d\u53ef\u7528\u7684\u7d22\u5f15\u3002<\/li>\n<li> <strong>key<\/strong>\uff1a\u67e5\u8be2\u4e2d\u5b9e\u9645\u4f7f\u7528\u7684\u7d22\u5f15\u3002<\/li>\n<li> <strong>rows<\/strong>\uff1aMySQL \u4f30\u8ba1\u5757\u4e2d\u5904\u7406\u7684\u884c\u6570\u3002<\/li>\n<li> <strong>filtered<\/strong>\uff1a\u67e5\u8be2\u4e2d\u5904\u7406\u7684\u884c\u6570\u7684\u767e\u5206\u6bd4\u3002<\/li>\n<li> <strong>Extra<\/strong>\uff1a\u6709\u5173\u5757\u64cd\u4f5c\u7684\u5176\u4ed6\u4fe1\u606f\u3002<\/li>\n<\/ul>\n<p><strong>\u89e3\u91ca\u6267\u884c\u8ba1\u5212<\/strong><\/p>\n<p>\u6267\u884c\u8ba1\u5212\u7684\u76ee\u7684\u662f\u786e\u5b9a\u67e5\u8be2\u7684\u74f6\u9888\u6240\u5728\u3002\u8981\u8fdb\u884c\u89e3\u91ca\uff0c\u8bf7\u6267\u884c\u4ee5\u4e0b\u6b65\u9aa4\uff1a<\/p>\n<ol>\n<li> <strong>\u68c0\u67e5 id<\/strong>\uff1a\u786e\u5b9a\u67e5\u8be2\u5757\u7684\u987a\u5e8f\u3002<\/li>\n<li> <strong>\u5206\u6790 select_type<\/strong>\uff1a\u8bc6\u522b\u67e5\u8be2\u4e2d\u7684\u5b50\u67e5\u8be2\u6216\u6d3e\u751f\u8868\u3002<\/li>\n<li> <strong>\u67e5\u770b table<\/strong>\uff1a\u786e\u5b9a\u67e5\u8be2\u4e2d\u6d89\u53ca\u7684\u8868\u3002<\/li>\n<li> <strong>\u68c0\u67e5 type<\/strong>\uff1a\u4e86\u89e3 MySQL \u5982\u4f55\u8bbf\u95ee\u8868\u3002<\/li>\n<li> <strong>\u8bc4\u4f30 possible_keys \u548c key<\/strong>\uff1a\u786e\u5b9a\u662f\u5426\u4f7f\u7528\u4e86\u7d22\u5f15\u4ee5\u53ca\u4f7f\u7528\u7684\u7d22\u5f15\u662f\u5426\u662f\u6700\u4f18\u7684\u3002<\/li>\n<li> <strong>\u5206\u6790 rows \u548c filtered<\/strong>\uff1a\u4f30\u7b97\u67e5\u8be2\u5904\u7406\u7684\u884c\u6570\u4ee5\u53ca\u4f7f\u7528\u7684\u7d22\u5f15\u7684\u8fc7\u6ee4\u6548\u7387\u3002<\/li>\n<li> <strong>\u5ba1\u67e5 Extra<\/strong>\uff1a\u67e5\u627e\u6709\u5173\u67e5\u8be2\u6027\u80fd\u7684\u5176\u4ed6\u91cd\u8981\u4fe1\u606f\u3002<\/li>\n<\/ol>\n<p><strong>\u4f18\u5316\u67e5\u8be2<\/strong><\/p>\n<p>\u57fa\u4e8e\u6267\u884c\u8ba1\u5212\u4e2d\u7684\u4fe1\u606f\uff0c\u60a8\u53ef\u4ee5\u91c7\u53d6\u4ee5\u4e0b\u6b65\u9aa4\u4f18\u5316\u67e5\u8be2\uff1a<\/p>\n<ul>\n<li>\u521b\u5efa\u6216\u8c03\u6574\u7d22\u5f15\u4ee5\u63d0\u9ad8\u6027\u80fd\u3002<\/li>\n<li>\u8c03\u6574\u67e5\u8be2\u4ee5\u51cf\u5c11\u5904\u7406\u7684\u884c\u6570\u3002<\/li>\n<li>\u4f18\u5316\u67e5\u8be2\u8ba1\u5212\u4ee5\u4f7f\u7528\u66f4\u6709\u6548\u7684\u7c7b\u578b\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u6267\u884c\u8ba1\u5212\u600e\u4e48\u5199\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u7f51\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u4f55\u64b0\u5199 \u6267\u884c\u8ba1\u5212 MySQL \u6267\u884c\u8ba1\u5212\u662f\u4f18\u5316\u67e5\u8be2\u6027\u80fd\u7684\u5173\u952e\u5de5\u5177\uff0c\u5b83\u6982\u8ff0\u4e86 MySQL \u5904\u7406\u67e5\u8be2\u7684\u6b65\u9aa4\u3002\u672c\u6307\u5357\u5c06\u5411\u60a8\u5c55\u793a\u5982\u4f55\u521b\u5efa\u548c\u89e3\u91ca MySQL \u6267\u884c\u8ba1\u5212\u3002 \u5982\u4f55\u521b\u5efa\u6267\u884c\u8ba1\u5212 \u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u751f\u6210\u6267\u884c\u8ba1\u5212\uff1a EXPLAIN [FORMAT = {JSON | TREE | TRADITIONAL}] &lt;\u67e5\u8be2&gt; \u767b\u5f55\u540e\u590d\u5236 FORMAT=JSON\uff1a\u4ee5 JSON \u683c\u5f0f\u8f93\u51fa\u8ba1\u5212\u3002 FORMAT=TREE\uff1a\u4ee5\u6811\u5f62\u7ed3\u6784\u8f93\u51fa\u8ba1\u5212\u3002 FORMAT=TRADITIONAL\uff1a\u4ee5\u4f20\u7edf\u6587\u672c\u683c\u5f0f\u8f93\u51fa\u8ba1\u5212\u3002 \u6267\u884c\u8ba1\u5212\u7684\u7ed3\u6784 \u6267\u884c\u8ba1\u5212\u7531\u4ee5\u4e0b\u90e8\u5206\u7ec4\u6210\uff1a id\uff1a\u67e5\u8be2\u5757\u7684\u552f\u4e00\u6807\u8bc6\u7b26\u3002 select_type\uff1a\u5757\u7684\u7c7b\u578b\uff0c\u4f8b\u5982 PRIMARY\u3001SUBQUERY\u3002 table\uff1a\u5757\u4e2d\u6d89\u53ca\u7684\u8868\u3002 type\uff1a\u5757\u7684\u7c7b\u578b\uff0c\u4f8b\u5982 ALL\u3001INDEX\u3001RANGE\u3002 possible_keys\uff1a\u67e5\u8be2\u4e2d\u53ef\u7528\u7684\u7d22\u5f15\u3002 key\uff1a\u67e5\u8be2\u4e2d\u5b9e\u9645\u4f7f\u7528\u7684\u7d22\u5f15\u3002 rows\uff1aMySQL \u4f30\u8ba1\u5757\u4e2d\u5904\u7406\u7684\u884c\u6570\u3002 filtered\uff1a\u67e5\u8be2\u4e2d\u5904\u7406\u7684\u884c\u6570\u7684\u767e\u5206\u6bd4\u3002 Extra\uff1a\u6709\u5173\u5757\u64cd\u4f5c\u7684\u5176\u4ed6\u4fe1\u606f\u3002 \u89e3\u91ca\u6267\u884c\u8ba1\u5212 \u6267\u884c\u8ba1\u5212\u7684\u76ee\u7684\u662f\u786e\u5b9a\u67e5\u8be2\u7684\u74f6\u9888\u6240\u5728\u3002\u8981\u8fdb\u884c\u89e3\u91ca\uff0c\u8bf7\u6267\u884c\u4ee5\u4e0b\u6b65\u9aa4\uff1a \u68c0\u67e5 id\uff1a\u786e\u5b9a\u67e5\u8be2\u5757\u7684\u987a\u5e8f\u3002 \u5206\u6790 select_type\uff1a\u8bc6\u522b\u67e5\u8be2\u4e2d\u7684\u5b50\u67e5\u8be2\u6216\u6d3e\u751f\u8868\u3002 \u67e5\u770b table\uff1a\u786e\u5b9a\u67e5\u8be2\u4e2d\u6d89\u53ca\u7684\u8868\u3002 \u68c0\u67e5 type\uff1a\u4e86\u89e3 MySQL \u5982\u4f55\u8bbf\u95ee\u8868\u3002 \u8bc4\u4f30 possible_keys \u548c key\uff1a\u786e\u5b9a\u662f\u5426\u4f7f\u7528\u4e86\u7d22\u5f15\u4ee5\u53ca\u4f7f\u7528\u7684\u7d22\u5f15\u662f\u5426\u662f\u6700\u4f18\u7684\u3002 [&hellip;]<\/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-5258","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5258","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=5258"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5258\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=5258"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=5258"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=5258"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}