{"id":149115,"date":"2020-08-17T07:13:03","date_gmt":"2020-08-16T23:13:03","guid":{"rendered":"http:\/\/4563.org\/?p=149115"},"modified":"2020-08-17T07:13:03","modified_gmt":"2020-08-16T23:13:03","slug":"mysql-%e6%9f%a5%e8%af%a2%e8%af%ad%e5%8f%a5%e6%89%a7%e8%a1%8c%e9%a1%ba%e5%ba%8f%e7%96%91%e9%97%ae%ef%bc%9a%e5%a4%9a%e8%a1%a8%e5%85%b3%e8%81%94%e6%97%b6%e4%bc%9a%e5%85%88%e7%94%9f%e6%88%90%e7%ac%9b","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=149115","title":{"rendered":"MySQL \u67e5\u8be2\u8bed\u53e5\u6267\u884c\u987a\u5e8f\u7591\u95ee\uff1a\u591a\u8868\u5173\u8054\u65f6\u4f1a\u5148\u751f\u6210\u7b1b\u5361\u5c14\u4e58\u79ef\uff1f"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  MySQL \u67e5\u8be2\u8bed\u53e5\u6267\u884c\u987a\u5e8f\u7591\u95ee\uff1a\u591a\u8868\u5173\u8054\u65f6\u4f1a\u5148\u751f\u6210\u7b1b\u5361\u5c14\u4e58\u79ef\uff1f               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : rainbirda <\/span>  <span><i><\/i> 14<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<h2>\u80cc\u666f<\/h2>\n<p>\u4e4b\u524d\u4e00\u76f4\u4ee5\u4e3a MySQL \u7684\u591a\u8868\u5173\u8054\u67e5\u8be2\u8bed\u53e5\u662f\u9996\u5148\u5bf9 FROM \u8bed\u53e5\u7684\u524d\u4e24\u5f20\u8868\u6267\u884c\u7b1b\u5361\u5c14\u79ef\uff0c\u4ea7\u751f\u4e00\u5f20\u865a\u62df\u8868\uff0c\u7136\u540e\u4f7f\u7528 ON \u8fc7\u6ee4\u548c OUTER JOIN \u6dfb\u52a0\u5916\u90e8\u884c\uff0c\u518d\u4f7f\u7528\u8fc7\u6ee4\u540e\u7684\u865a\u62df\u8868\u8ddf\u7b2c\u4e09\u5f20\u8868\u8fdb\u884c\u7b1b\u5361\u5c14\u4e58\u79ef\uff0c\u91cd\u590d\u6267\u884c\u4e0a\u8ff0\u6b65\u9aa4\u3002\u4e0b\u9762\u662f\u4ece\u7f51\u4e0a\u641c\u5230\u4e00\u4e9b\u6bd4\u8f83\u70ed\u95e8\u7684 SQL \u6267\u884c\u987a\u5e8f\u7684\u6587\u7ae0\uff0c\u5927\u5bb6\u5e94\u8be5\u5f88\u719f\u6089\u5427\uff0c\u5c24\u5176\u662f\u4e0b\u9762\u90a3\u5f20\u9c7c\u9aa8\u56fe\u3002 <img decoding=\"async\" src=\"http:\/\/4563.org\/wp-content\/uploads\/2020\/09\/20200905_5f53775f453cb.png\" alt=\"MySQL \u67e5\u8be2\u8bed\u53e5\u6267\u884c\u987a\u5e8f\u7591\u95ee\uff1a\u591a\u8868\u5173\u8054\u65f6\u4f1a\u5148\u751f\u6210\u7b1b\u5361\u5c14\u4e58\u79ef\uff1f\" \/> \u6458\u81ea\uff1a\u6b65\u6b65\u6df1\u5165\uff1aMySQL \u67b6\u6784\u603b\u89c8-&gt;\u67e5\u8be2\u6267\u884c\u6d41\u7a0b-&gt;SQL \u89e3\u6790\u987a\u5e8f<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/4563.org\/wp-content\/uploads\/2020\/09\/20200905_5f5377634fb79.png\" alt=\"MySQL \u67e5\u8be2\u8bed\u53e5\u6267\u884c\u987a\u5e8f\u7591\u95ee\uff1a\u591a\u8868\u5173\u8054\u65f6\u4f1a\u5148\u751f\u6210\u7b1b\u5361\u5c14\u4e58\u79ef\uff1f\" \/> \u6458\u81ea\uff1aMysql &#8211; JOIN \u8be6\u89e3<\/p>\n<h2>\u95ee\u9898\u63cf\u8ff0<\/h2>\n<p>\u6700\u8fd1\u7531\u4e8e\u5de5\u4f5c\u9700\u8981\uff0c\u5bf9 SQL \u67e5\u8be2\u6027\u80fd\u8981\u6c42\u6bd4\u8f83\u9ad8\uff0c\u9605\u8bfb\u4e86\u300a\u9ad8\u6027\u80fd MySQL \uff08\u7b2c 3 \u7248\uff09\u300b\u67e5\u8be2\u4f18\u5316\u7684\u76f8\u5173\u7ae0\u8282\uff0c\u5728\u201c6.4.3 \u67e5\u8be2\u4f18\u5316\u5904\u7406\u201d\u7ae0\u8282\u6709\u8fd9\u6837\u4e00\u53e5\u8bdd:<\/p>\n<blockquote>\n<p><strong>MySQL \u5bf9\u4efb\u4f55\u5173\u8054\u90fd\u6267\u884c\u5d4c\u5957\u5faa\u73af\u5173\u8054\u64cd\u4f5c<\/strong>\uff0c\u5373 MySQL \u5148\u5728\u4e00\u4e2a\u8868\u4e2d\u5faa\u73af\u8bfb\u53d6\u5355\u6761\u6570\u636e\uff0c\u7136\u540e\u518d\u5d4c\u5957\u5faa\u73af\u5230\u4e0b\u4e00\u4e2a\u8868\u4e2d\u5bfb\u627e\u5339\u914d\u7684\u884c\uff0c\u4f9d\u6b21\u4e0b\u53bb\uff0c\u76f4\u5230\u627e\u5230\u6240\u6709\u8868\u4e2d\u5339\u914d\u7684\u884c\u4e3a\u6b62\u3002\u7136\u540e\u6839\u636e\u5404\u4e2a\u8868\u5339\u914d\u7684\u884c\uff0c\u8fd4\u56de\u67e5\u8be2\u4e2d\u9700\u8981\u7684\u5404\u4e2a\u5217\u3002MySQL \u4f1a\u5c1d\u8bd5\u5728\u6700\u540e\u4e00\u4e2a\u5173\u8054\u8868\u4e2d\u627e\u5230\u6240\u6709\u5339\u914d\u7684\u884c\uff0c\u5982\u679c\u6700\u540e\u4e00\u4e2a\u5173\u8054\u8868\u65e0\u6cd5\u627e\u5230\u66f4\u591a\u7684\u884c\u4ee5\u540e\uff0cMySQL \u8fd4\u56de\u5230\u4e0a\u4e00\u5c42\u6b21\u5173\u8054\u8868\uff0c\u770b\u662f\u5426\u80fd\u591f\u627e\u5230\u66f4\u591a\u7684\u5339\u914d\u8bb0\u5f55\uff0c\u4f9d\u6b21\u7c7b\u63a8\u8fed\u4ee3\u6267\u884c\u3002<\/p>\n<\/blockquote>\n<p>\u4e8e\u662f\u5bf9\u4e4b\u524d\u7684\u8ba4\u8bc6\u4ea7\u751f\u6000\u7591\uff0c\u5982\u679c\u6240\u6709\u5173\u8054\u90fd\u662f\u5d4c\u5957\u5faa\u73af\u5173\u8054\u67e5\u8be2\u7684\u8bdd\uff0c\u53ea\u6709\u5f53\u6ca1\u6709\u4efb\u4f55\u8fc7\u6ee4\u6761\u4ef6\u65f6\u4e24\u5f20\u8868\u624d\u4f1a\u4ea7\u751f\u7b1b\u5361\u5c14\u4e58\u79ef\uff0c\u800c\u4e14\u8fd9\u4e2a\u7b1b\u5361\u5c14\u4e58\u79ef\u662f\u4e00\u4e2a\u7ed3\u679c\uff0c\u5e76\u4e0d\u662f\u5173\u8054\u67e5\u8be2\u7684\u6b65\u9aa4\uff0c\u800c\u4e14\u5982\u679c\u4e24\u5f20\u51e0\u5341\u4e07\u3001\u4e0a\u767e\u4e07\u7684\u8868\u8fdb\u884c\u7b1b\u5361\u5c14\u4e58\u79ef\uff0c\u8fd9\u6570\u636e\u91cf\u6709\u70b9\u5de8\u5927\u4e86\u3002\u3002\u3002\u5728 MySQL \u7684\u5b98\u65b9\u624b\u518c \u4e2d\u4e5f\u5370\u8bc1\u4e86\u5d4c\u5957\u5faa\u73af\u64cd\u4f5c\uff1a<img decoding=\"async\" src=\"http:\/\/4563.org\/wp-content\/uploads\/2020\/09\/20200905_5f53776b034ae.png\" alt=\"MySQL \u67e5\u8be2\u8bed\u53e5\u6267\u884c\u987a\u5e8f\u7591\u95ee\uff1a\u591a\u8868\u5173\u8054\u65f6\u4f1a\u5148\u751f\u6210\u7b1b\u5361\u5c14\u4e58\u79ef\uff1f\" \/><\/p>\n<p>\u5728\u535a\u5ba2\u56ed\u627e\u5230 \u795e\u5947\u7684 SQL \u4e4b \u8054\u8868\u7ec6\u8282 \u2192 MySQL JOIN \u7684\u6267\u884c\u8fc7\u7a0b\uff08\u4e00\uff09 \u8fd9\u7bc7\u535a\u5ba2\u5bf9\u4e0a\u8ff0\u7b1b\u5361\u5c14\u4e58\u79ef\u4e5f\u6709\u540c\u6837\u7684\u7591\u95ee\uff0c\u800c\u4e14\u7ed9\u51fa\u4e86\u5b9e\u9645\u7684\u6848\u4f8b\u5206\u6790\uff0c\u4e2a\u4eba\u6bd4\u8f83\u8ba4\u540c\u8be5\u535a\u4e3b\u7684\u89c2\u70b9\u3002\u91cc\u9762\u6709\u8fd9\u6837\u4e00\u4e2a\u6848\u4f8b\uff1a <img decoding=\"async\" src=\"http:\/\/4563.org\/wp-content\/uploads\/2020\/09\/20200905_5f537770e3d0d.png\" alt=\"MySQL \u67e5\u8be2\u8bed\u53e5\u6267\u884c\u987a\u5e8f\u7591\u95ee\uff1a\u591a\u8868\u5173\u8054\u65f6\u4f1a\u5148\u751f\u6210\u7b1b\u5361\u5c14\u4e58\u79ef\uff1f\" \/><\/p>\n<p>\u4ece\u8fd9\u4e2a\u6848\u4f8b\u53ef\u4ee5\u770b\u51fa\u5f53\u67e5\u8be2\u4f18\u5316\u5668\u4f7f\u7528 <strong>Index Nested-Loop<\/strong> \u5373\u7d22\u5f15\u5d4c\u5957\u5faa\u73af\uff0cWHERE \u6761\u4ef6\u9996\u5148\u901a\u8fc7\u7d22\u5f15\u8fc7\u6ee4\u9a71\u52a8\u8868\u7684\u6570\u636e\u7136\u540e\u518d\u5173\u8054\u88ab\u9a71\u52a8\u8868\uff0c\u66f4\u52a0\u5370\u8bc1\u4e86 WHERE \u4e0d\u662f\u5728\u4e24\u8868\u751f\u6210\u7b1b\u5361\u5c14\u4e58\u79ef\u540e\u624d\u8fdb\u884c\u8fc7\u6ee4\u7684\u3002\u5982\u679c\u4ece\u201c\u5d4c\u5957\u5faa\u73af\u5173\u8054\u201d\u7684\u89d2\u5ea6\u770b\uff0c\u4e4b\u524d\u7684\u5173\u8054\u8868\u5148\u751f\u6210\u7b1b\u5361\u5c14\u4e58\u79ef\u518d\u8fdb\u884c\u8fc7\u6ee4\u7684\u7406\u8bba\u662f\u7ad9\u4e0d\u4f4f\u811a\u7684\u3002<\/p>\n<p>\u90a3\u4e48\u95ee\u9898\u5c31\u662f<strong>\u8fd9\u79cd\u201c\u7b1b\u5361\u5c14\u4e58\u79ef\u8fc7\u6ee4\u201d\u7684\u7406\u8bba\u6709\u4ec0\u4e48\u5386\u53f2\u539f\u56e0\u5417\uff0c\u4e3a\u4ec0\u4e48\u7f51\u4e0a\u7684\u6587\u7ae0\u5927\u90e8\u5206\u90fd\u662f\u8fd9\u79cd\uff0c\u8fd8\u662f\u6211\u5bf9\u201c\u5d4c\u5957\u5faa\u73af\u67e5\u8be2\u201d\u6709\u8bef\u89e3\uff1f<\/strong> \u6211\u76f8\u4fe1\u6709\u4e0d\u5c11\u5c0f\u4f19\u4f34\u8ddf\u6211\u4e00\u6837\u7684\u7591\u60d1\u5427\uff0c\u8fd8\u671b V \u7ad9\u5927\u4f6c\u7ed9\u6307\u70b9\u8ff7\u6d25\u3002<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>12<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"3098766\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : fuyufjh <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             1. \u4f60\u56fe\u88c2\u4e86<br \/>2. \u201c\u7b1b\u5361\u5c14\u79ef\u518d\u8fc7\u6ee4\u201d\u662f\u5e2e\u52a9\u4f60\u7406\u89e3 Join \u8bed\u4e49\u7684\uff0c\u5b9e\u9645\u4e0a\u57fa\u672c\u4e0d\u4f1a\u8fd9\u4e48\u6267\u884c\uff08\u9664\u975e Join \u4e0d\u5305\u542b\u7b49\u503c\u6761\u4ef6\uff09<br \/>3. \u5bf9\u4e8e\u6709\u7d22\u5f15\u7684\u60c5\u51b5\uff0cnested-loop \uff08\u5d4c\u5957\u5faa\u73af\uff09\u662f\u5f88\u9ad8\u6548\u7684\u505a\u6cd5\uff0c\u6bcf\u6b21\u5faa\u73af\u5b9e\u9645\u4e0a\u662f\u5bf9\u5185\u8868\u7684\u4e00\u6b21 index lookup                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3098767\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : liprais <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u81ea\u5df1\u5199\u4e24\u4e2a sql \u770b\u770b\u6267\u884c\u8ba1\u5212\u4e0d\u5c31\u5b8c\u4e86                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3098768\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : rainbirda <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @fuyufjh \u55ef\uff0c\u4e4b\u524d\u4e5f\u6709\u8fd9\u6837\u60f3\u8fc7\u3002\u4f46\u662f\u4f7f\u7528\u201c\u7b1b\u5361\u5c14\u79ef\u518d\u8fc7\u6ee4\u201d\u5c31\u65e0\u6cd5\u5f88\u597d\u7684\u89e3\u91ca EXPLIAIN \u91cc\u7684\u5185\u5bb9\u3002\u5728 EXPLAIN \u91cc\u53ef\u4ee5\u6e05\u695a\u7684\u770b\u5230\u67e5\u8be2\u8ba1\u5212\u6bcf\u4e2a\u8868\u4f7f\u7528\u4ec0\u4e48\u7d22\u5f15\u3001\u8868\u626b\u63cf\u7684\u987a\u5e8f\u3001\u9884\u4f30\u7684\u884c\u6570\u7b49\uff0c\u5982\u679c\u4f7f\u7528\u201c\u5d4c\u5957\u5faa\u73af\u5173\u8054\u201d\u7684\u601d\u60f3\uff0c\u53ef\u4ee5\u5f88\u597d\u7684\u7406\u89e3 EXPLAIN \u4e86\uff0c\u800c\u4e4b\u524d\u201c\u7b1b\u5361\u5c14\u4e58\u79ef\u201d\u8fd9\u79cd\u4f1a\u8ba9\u4eba\u9677\u5165\u8bef\u533a\uff0c\u6211\u4e4b\u524d\u4e5f\u662f\u767e\u601d\u4e0d\u5f97\u5176\u89e3\u3002\u6211\u611f\u89c9\u8fd9\u79cd\u8bed\u4e49\u53ef\u80fd\u4f1a\u628a\u4e8b\u60c5\u592a\u7b80\u5355\u5316\uff0c\u5176\u5b9e\u5bf9\u5b9e\u9645\u7684\u67e5\u8be2\u4f18\u5316\u6ca1\u6709\u5e2e\u52a9\uff0c\u800c\u4e14\u4f1a\u8bef\u5bfc\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3098769\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : dingyaguang117 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u7b1b\u5361\u5c14\u79ef \u80af\u5b9a\u662f\u4e0d\u53ef\u80fd\u8fd9\u4e48\u5b9e\u73b0\u7684\u3002\u5185\u5b58\u80fd\u63a5\u53d7\u5f97\u4e86\u5417                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3098770\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : rainbirda <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @dingyaguang117 \u662f\u7684 \u6240\u4ee5\u4e0d\u77e5\u9053\u7f51\u4e0a\u90a3\u4e9b\u6587\u7ae0\u662f\u4e0d\u662f\u6709\u4ec0\u4e48\u7edf\u4e00\u7684\u51fa\u5904\uff0c\u6216\u8005\u662f\u5386\u53f2\u539f\u56e0\uff1f\u6211\u770b\u8fd9\u4e9b\u90fd\u6ca1\u6709\u7528\u7b1b\u5361\u5c14\u4e58\u79ef\u89e3\u91ca EXPLAIN \u7684\u67e5\u8be2\u8ba1\u5212\u662f\u600e\u4e48\u8fd0\u884c\u7684\uff0c\u800c\u4e14\u9762\u8bd5\u65f6\u4e5f\u7ecf\u5e38\u4f1a\u88ab\u95ee\u5230\u8fd9\u79cd\u95ee\u9898\uff0c\u7b54\u6848\u8ddf\u8fd9\u4e9b\u6587\u7ae0\u4e5f\u662f\u4e00\u6837\u7684                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3098771\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : daozhihun <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4e2a\u4eba\u8ba4\u4e3a\u7f51\u4e0a\u8bf4\u7684\u201c\u7b1b\u5361\u5c14\u79ef\u8fc7\u6ee4\u201d\u53ea\u662f\u6570\u5b66\u4e0a\u7684\u7b49\u4ef7\uff0c\u65b9\u4fbf\u4f60\u7406\u89e3\uff0c\u5b9e\u9645\u4e0a\u5f15\u64ce\u4f1a\u6839\u636e\u5404\u79cd\u60c5\u51b5\u627e\u4f18\u5316\u3002\u5c31\u6bd4\u5982\u4e0d\u540c\u7684\u7b97\u6cd5\u53bb\u7b97\u6b63\u5f26\u503c\uff0c\u53ef\u80fd\u4ece\u7406\u89e3\u7684\u89d2\u5ea6\u5dee\u4e0d\u591a\uff0c\u4f46\u5b9e\u9645\u4e0a\u8fd8\u662f\u6709\u5f88\u5927\u533a\u522b\u7684\u3002<br \/>\u800c\u4e14\u5f15\u64ce\u6709\u65f6\u5019\u4e5f\u4e0d\u662f\u5f88\u667a\u80fd\uff0c\u67d0\u4e9b\u60c5\u51b5\u8fd8\u662f\u8981\u81ea\u5df1\u4f18\u5316\u3002\u4e4b\u524d\u6211\u4eec\u5c31\u9047\u5230\u8fc7\u7c7b\u4f3c\u60c5\u51b5\uff0c\u5148\u8fc7\u6ee4\u6389\u5927\u8303\u56f4\u4e0d\u5339\u914d\u7684\uff0c\u5269\u4e0b\u7684\u518d\u53bb join \u6548\u679c\u4f1a\u5f88\u597d\uff08\u5f53\u7136\u770b\u60c5\u51b5\uff09                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3098772\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : dingyaguang117 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @rainbirda \u53e6\u5916\u6211\u8fd8\u5bf9 in \u67e5\u8be2\u7684 \u8fd0\u884c\u6d41\u7a0b\u6bd4\u8f83\u611f\u5174\u8da3\uff0cLZ \u4e86\u89e3\u5417                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3098773\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : rainbirda <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @dingyaguang117 \u5f15\u7528\u300a\u9ad8\u6027\u80fd MySQL \uff08\u7b2c 3 \u7248\uff09\u300b 6.4.3 \u67e5\u8be2\u4f18\u5316\u5904\u7406\u7ae0\u8282\u7684\u5217\u8868 \u201cIN()\u7684\u6bd4\u8f83\u201d<\/p>\n<p>&gt; \u5728\u5f88\u591a\u6570\u636e\u5e93\u7cfb\u7edf\u4e2d,IN()\u5b8c\u5168\u7b49\u540c\u4e8e\u591a\u4e2a 0R \u6761\u4ef6\u7684\u5b50\u53e5,\u56e0\u4e3a\u8fd9\u4e24\u8005\u662f\u5b8c\u5168\u7b49\u4ef7\u7684\u3002\u5728 MySQL \u4e2d\u8fd9\u70b9\u662f\u4e0d\u6210\u7acb\u7684, MySQL \u5c06 IN()\u5217\u8868\u4e2d\u7684\u6570\u636e\u5148\u8fdb\u884c\u6392\u5e8f ,\u7136\u540e\u901a\u8fc7\u4e8c\u5206\u67e5\u627e\u7684\u65b9\u5f0f\u6765\u786e\u5b9a\u5217\u8868\u4e2d\u7684\u503c\u662f\u5426\u6ee1\u8db3\u6761\u4ef6,\u8fd9\u662f\u4e00\u4e2a O(logn)\u590d\u6742 \u5ea6\u7684\u64cd\u4f5c,\u7b49\u4ef7\u5730\u8f6c\u6362\u6210 OR \u67e5\u8be2\u7684\u590d\u6742\u5ea6\u4e3a O(n),\u5bf9\u4e8e IN()\u5217\u8868\u4e2d\u6709\u5927\u91cf\u53d6\u503c\u7684\u65f6\u5019, MySQL \u7684\u5904\u7406\u901f\u5ea6\u5c06\u4f1a\u66f4\u5feb\u3002<\/p>\n<p>\u4f46\u662f\u8fd9\u4e2a\u4e8c\u5206\u67e5\u627e\u662f\u600e\u4e48\u52a0\u5feb\u5904\u7406\u901f\u5ea6\u7684\uff0c\u8fd8\u7406\u89e3\u4e0d\u4e86\uff0c\u4e5f\u6ca1\u627e\u5230\u76f8\u5173\u8d44\u6599\uff0c\u4f60\u770b\u770b\u8fd9\u4e2a\u80fd\u7406\u89e3\u4e0d                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3098774\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : rainbirda <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @daozhihun \u55ef \u6211\u660e\u767d\u4f60\u7684\u610f\u601d\uff0c\u4e0d\u8fc7\u5e94\u8be5\u662f\u5728\u6ca1\u6709\u8fde\u63a5\u6761\u4ef6\u7684\u60c5\u51b5\u4e0b\u5728\u8bed\u4e49\u4e0a\u662f\u4e0e\u7b1b\u5361\u5c14\u4e58\u79ef\u662f\u7b49\u4ef7\u7684\u5427\uff0c\u5176\u4ed6\u7684\u60c5\u51b5\u4e0b\u67e5\u8be2\u4f18\u5316\u5668\u5b9e\u9645\u8fd0\u884c\u7684\u60c5\u51b5\u4f1a\u5f88\u590d\u6742\uff0c\u6ca1\u6709\u5b8c\u5168\u6309\u7167\u67d0\u79cd\u56fa\u5b9a\u7684\u987a\u5e8f\u6267\u884c                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3098775\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : daozhihun <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @rainbirda \u662f\u7684\uff0c\u5c31\u597d\u6bd4\u300a\u7f16\u8bd1\u539f\u7406\u300b\u8fd9\u672c\u4e66\u8bb2\u4e86\u4e00\u4e9b\u8bbe\u8ba1\u548c\u539f\u7406\u4e0a\u7684\u4e1c\u897f\uff0c\u4f46\u662f\u5b9e\u9645\u4e0a\u4e00\u4e2a\u7f16\u8bd1\u5668\u662f\u975e\u5e38\u5de8\u5927\u7684\u5de5\u7a0b\uff0c\u4e00\u672c\u4e66\u662f\u4e0d\u53ef\u80fd\u8986\u76d6\u5168\u7684\u3002\u60f3\u8981\u4e86\u89e3\u5177\u4f53\u6bcf\u4e00\u4e2a\u7ec6\u8282\u662f\u600e\u4e48\u505a\u7684\uff0c\u4f30\u8ba1\u53ea\u6709\u53bb\u5206\u6790\u6e90\u7801\u4e86\uff0c\u7f51\u4e0a\u7684\u90fd\u662f\u4e00\u4e9b\u7ecf\u9a8c\u6027\u3001\u6bd4\u8f83\u7b3c\u7edf\u7684\u4e1c\u897f\uff0c\u4f18\u5316\u5668\u771f\u6b63\u6267\u884c\u7684\u65f6\u5019\u8fdc\u6bd4\u8fd9\u4e2a\u590d\u6742                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3098776\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : rainbirda <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @daozhihun \u55ef\uff0c\u6df1\u611f\u8ba4\u540c\uff0c\u786e\u5b9e\u53ea\u6709\u5206\u6790\u6e90\u7801\u624d\u80fd\u771f\u6b63\u660e\u767d\u80cc\u540e\u7684\u539f\u7406\u3002\u6bcf\u4e2a\u4eba\u7cbe\u529b\u4e5f\u662f\u6bd4\u8f83\u6709\u9650\uff0c\u5927\u90e8\u5206\u65f6\u5019\u53ea\u80fd\u7ba1\u4e2d\u7aa5\u8c79\uff0c\u6709\u53ef\u80fd\u7aa5\u7684\u8fd8\u4e0d\u4e00\u5b9a\u662f\u8c79\u3002\u3002\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3098777\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : zhangysh1995 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @rainbirda \u5bf9\u4e8e\u5173\u7cfb\u4ee3\u6570\u91cc\u9762\u7684 formal \u5b9a\u4e49\uff0c\u7b1b\u5361\u5c14\u79ef\u548c JOIN \u662f\u4e0d\u4e00\u6837\u7684\u3002<\/p>\n<p>\u5047\u8bbe\u6709\u4e24\u5f20\u8868 R1, R2, \u5206\u522b\u884c\u8868\u793a\u4e3a t1, t2\uff0c \u90a3\u4e48\uff1a<br \/>* \u7b1b\u5361\u5c14\u79ef\u7684\u7ed3\u679c\u662f\u53d6\u6240\u6709\u7684 t1, t2, \u8fd4\u56de (t1,t2) \u62fc\u63a5\u7684\u7ed3\u679c\uff1b<br \/>* JOIN \u662f\u6839\u636e\u7ed9\u5b9a\u7684\u8c13\u8bcd predicate\uff0c\u5224\u65ad t1, t2 \u662f\u5426\u6ee1\u8db3\uff0c\u6ee1\u8db3\u7684\u8bdd\u8fd4\u56de\u62fc\u63a5\u7ed3\u679c\u3002<\/p>\n<p>\u6982\u5ff5\u4e0a\uff0cJOIN \u7684\u64cd\u4f5c\u786e\u5b9e\u53ef\u4ee5\u7406\u89e3\u4e3a\u5148\u7b1b\u5361\u5c14\u79ef\u518d\u8fc7\u6ee4\uff0c\u4f46\u662f\u5b9e\u9645\u4e0d\u4f1a\u8fd9\u4e48\u64cd\u4f5c\uff0c\u56e0\u4e3a\u6027\u80fd\u539f\u56e0\u3002\u5bf9\u4e8e JOIN \u7684\u4f18\u5316\u9996\u5148\u662f \u903b\u8f91\u8ba1\u5212\uff0c\u6bd4\u5982 MySQL `straight_join` \u5c31\u662f\u4e00\u4e2a\u4eba\u5de5\u5f3a\u5236\u7684\u903b\u8f91\u65b9\u6848\u3002<\/p>\n<p>\u53e6\u5916 Nested-Loop Join \u7b97\u6cd5\u662f\u6240\u79f0\u7684 \u7269\u7406\u8ba1\u5212\uff0c\u7406\u89e3\u4e3a\u5728\u5b58\u7684\u6570\u636e\u96c6\u4e0a\u5982\u4f55\u8fdb\u884c\u5b58\u53d6\u3002                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>MySQL \u67e5\u8be2\u8bed\u53e5\u6267\u884c\u987a\u5e8f\u7591\u95ee\uff1a&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/149115"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=149115"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/149115\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=149115"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=149115"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=149115"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}