{"id":27584,"date":"2024-11-24T14:59:42","date_gmt":"2024-11-24T06:59:42","guid":{"rendered":"https:\/\/fwq.ai\/blog\/27584\/"},"modified":"2024-11-24T14:59:42","modified_gmt":"2024-11-24T06:59:42","slug":"mysql-%e7%bb%84%e5%90%88%e7%b4%a2%e5%bc%95%e4%b8%ba%e4%bd%95%e5%a4%b1%e6%95%88%ef%bc%9a%e6%9f%a5%e8%af%a2%e9%80%89%e6%8b%a9%e6%89%80%e6%9c%89%e5%88%97%e4%bc%9a%e5%af%bc%e8%87%b4%e7%b4%a2%e5%bc%95-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/27584\/","title":{"rendered":"MySQL \u7ec4\u5408\u7d22\u5f15\u4e3a\u4f55\u5931\u6548\uff1a\u67e5\u8be2\u9009\u62e9\u6240\u6709\u5217\u4f1a\u5bfc\u81f4\u7d22\u5f15\u5931\u6548\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173129335935331.jpg\" class=\"aligncenter\" title=\"MySQL \u7ec4\u5408\u7d22\u5f15\u4e3a\u4f55\u5931\u6548\uff1a\u67e5\u8be2\u9009\u62e9\u6240\u6709\u5217\u4f1a\u5bfc\u81f4\u7d22\u5f15\u5931\u6548\uff1f\u63d2\u56fe\" alt=\"MySQL \u7ec4\u5408\u7d22\u5f15\u4e3a\u4f55\u5931\u6548\uff1a\u67e5\u8be2\u9009\u62e9\u6240\u6709\u5217\u4f1a\u5bfc\u81f4\u7d22\u5f15\u5931\u6548\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u7ec4\u5408\u7d22\u5f15\u672a\u751f\u6548\uff1a\u7406\u89e3\u67e5\u8be2\u5217\u5bf9\u7d22\u5f15\u4f7f\u7528\u7684\u5f71\u54cd<\/strong><\/p>\n<p>\u5728  \u4e2d\uff0c\u4f7f\u7528\u7ec4\u5408\u7d22\u5f15\u53ef\u4ee5\u663e\u7740\u63d0\u5347\u7279\u5b9a\u67e5\u8be2\u7684\u6027\u80fd\u3002\u7136\u800c\uff0c\u6709\u65f6\u7ec4\u5408\u7d22\u5f15\u53ef\u80fd\u65e0\u6cd5\u751f\u6548\uff0c\u8fd9\u53ef\u80fd\u662f\u7531\u67e5\u8be2\u7684\u5217\u51b3\u5b9a\u7684\u3002 <\/p>\n<p>\u8ba9\u6211\u4eec\u8003\u8651\u7ed9\u5b9a\u7684\u95ee\u9898\uff1a<\/p>\n<pre>explain select * from combine_indx where c = 3 and b = 4<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8be5\u67e5\u8be2\u6309 c \u548c b \u5217\u67e5\u627e\u8bb0\u5f55\u3002\u5728\u8868\u4e2d\uff0c\u6709\u4e00\u4e2a\u7ec4\u5408\u7d22\u5f15\u8986\u76d6\u8fd9\u4e24\u79cd\u5217\u3002\u7136\u800c\uff0c\u6267\u884c expln \u65f6\uff0csql \u4f18\u5316\u5668\u672a\u4f7f\u7528\u7d22\u5f15\uff0c\u800c\u662f\u9009\u62e9\u4e86\u5168\u8868\u626b\u63cf (all)\u3002 <\/p>\n<p>\u539f\u56e0\u5728\u4e8e\u8be5\u67e5\u8be2\u4e2d\u4f7f\u7528\u4e86 select *\uff0c\u5b83\u5c06\u68c0\u7d22\u6240\u6709\u5217\uff08\u5305\u62ec\u672a\u5305\u542b\u5728\u7ec4\u5408\u7d22\u5f15\u4e2d\u7684\u5217\uff09\uff0c\u8fd9\u8feb\u4f7f\u6570\u636e\u5e93\u56de\u8868\u4ee5\u83b7\u53d6\u8fd9\u4e9b\u5217\u7684\u6570\u636e\u3002\u56de\u8868\u4f1a\u5bfc\u81f4\u7d22\u5f15\u5931\u6548\uff0c\u56e0\u4e3a\u9700\u8981\u626b\u63cf\u6574\u4e2a\u8868\u6765\u83b7\u53d6\u6240\u9700\u6570\u636e\u3002 <\/p>\n<p>\u8981\u89e3\u51b3\u6b64\u95ee\u9898\uff0c\u53ef\u4ee5\u4fee\u6539\u67e5\u8be2\u4ee5\u4ec5\u9009\u62e9\u6240\u9700\u7684\u5217\uff1a<\/p>\n<pre>EXPLAIN SELECT b, c FROM combine_indx WHERE c = 3 and b = 4<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u901a\u8fc7\u53ea\u9009\u62e9b \u548cc \u5217\uff0c\u67e5\u8be2\u4e0d\u518d\u9700\u8981\u56de\u8868\uff0c\u56e0\u6b64\u7ec4\u5408\u7d22\u5f15\u53ef\u4ee5\u751f\u6548\uff0c\u8fd9\u5c06\u5bfc\u81f4\u7d22\u5f15\u67e5\u627e(index) \u800c\u4e0d\u662f\u5168\u8868\u626b\u63cf(all) \u7684\u6267\u884c\u8ba1\u5212\u3002 <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fMySQL \u7ec4\u5408\u7d22\u5f15\u4e3a\u4f55\u5931\u6548\uff1a\u67e5\u8be2\u9009\u62e9\u6240\u6709\u5217\u4f1a\u5bfc\u81f4\u7d22\u5f15\u5931\u6548\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>\u7ec4\u5408\u7d22\u5f15\u672a\u751f\u6548\uff1a\u7406\u89e3\u67e5\u8be2\u5217\u5bf9\u7d22\u5f15\u4f7f\u7528\u7684\u5f71\u54cd \u5728 \u4e2d\uff0c\u4f7f\u7528\u7ec4\u5408\u7d22\u5f15\u53ef\u4ee5\u663e\u7740\u63d0\u5347\u7279\u5b9a\u67e5\u8be2\u7684\u6027\u80fd\u3002\u7136\u800c\uff0c\u6709\u65f6\u7ec4\u5408\u7d22\u5f15\u53ef\u80fd\u65e0\u6cd5\u751f\u6548\uff0c\u8fd9\u53ef\u80fd\u662f\u7531\u67e5\u8be2\u7684\u5217\u51b3\u5b9a\u7684\u3002 \u8ba9\u6211\u4eec\u8003\u8651\u7ed9\u5b9a\u7684\u95ee\u9898\uff1a explain select * from combine_indx where c = 3 and b = 4 \u767b\u5f55\u540e\u590d\u5236 \u8be5\u67e5\u8be2\u6309 c \u548c b \u5217\u67e5\u627e\u8bb0\u5f55\u3002\u5728\u8868\u4e2d\uff0c\u6709\u4e00\u4e2a\u7ec4\u5408\u7d22\u5f15\u8986\u76d6\u8fd9\u4e24\u79cd\u5217\u3002\u7136\u800c\uff0c\u6267\u884c expln \u65f6\uff0csql \u4f18\u5316\u5668\u672a\u4f7f\u7528\u7d22\u5f15\uff0c\u800c\u662f\u9009\u62e9\u4e86\u5168\u8868\u626b\u63cf (all)\u3002 \u539f\u56e0\u5728\u4e8e\u8be5\u67e5\u8be2\u4e2d\u4f7f\u7528\u4e86 select *\uff0c\u5b83\u5c06\u68c0\u7d22\u6240\u6709\u5217\uff08\u5305\u62ec\u672a\u5305\u542b\u5728\u7ec4\u5408\u7d22\u5f15\u4e2d\u7684\u5217\uff09\uff0c\u8fd9\u8feb\u4f7f\u6570\u636e\u5e93\u56de\u8868\u4ee5\u83b7\u53d6\u8fd9\u4e9b\u5217\u7684\u6570\u636e\u3002\u56de\u8868\u4f1a\u5bfc\u81f4\u7d22\u5f15\u5931\u6548\uff0c\u56e0\u4e3a\u9700\u8981\u626b\u63cf\u6574\u4e2a\u8868\u6765\u83b7\u53d6\u6240\u9700\u6570\u636e\u3002 \u8981\u89e3\u51b3\u6b64\u95ee\u9898\uff0c\u53ef\u4ee5\u4fee\u6539\u67e5\u8be2\u4ee5\u4ec5\u9009\u62e9\u6240\u9700\u7684\u5217\uff1a EXPLAIN SELECT b, c FROM combine_indx WHERE c = 3 and b = 4 \u767b\u5f55\u540e\u590d\u5236 \u901a\u8fc7\u53ea\u9009\u62e9b \u548cc \u5217\uff0c\u67e5\u8be2\u4e0d\u518d\u9700\u8981\u56de\u8868\uff0c\u56e0\u6b64\u7ec4\u5408\u7d22\u5f15\u53ef\u4ee5\u751f\u6548\uff0c\u8fd9\u5c06\u5bfc\u81f4\u7d22\u5f15\u67e5\u627e(index) \u800c\u4e0d\u662f\u5168\u8868\u626b\u63cf(all) \u7684\u6267\u884c\u8ba1\u5212\u3002 \u4ee5\u4e0a\u5c31\u662fMySQL \u7ec4\u5408\u7d22\u5f15\u4e3a\u4f55\u5931\u6548\uff1a\u67e5\u8be2\u9009\u62e9\u6240\u6709\u5217\u4f1a\u5bfc\u81f4\u7d22\u5f15\u5931\u6548\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-27584","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/27584","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=27584"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/27584\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=27584"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=27584"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=27584"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}