{"id":207410,"date":"2025-07-08T08:10:08","date_gmt":"2025-07-08T00:10:08","guid":{"rendered":"https:\/\/server.hk\/cnblog\/207410\/"},"modified":"2025-07-08T08:10:08","modified_gmt":"2025-07-08T00:10:08","slug":"%e5%bd%93%e5%9c%a8%e4%bb%a3%e7%a0%81%e4%b8%ad%e4%bd%9c%e4%b8%ba%e5%87%86%e5%a4%87%e5%a5%bd%e7%9a%84%e8%af%ad%e5%8f%a5%e8%bf%90%e8%a1%8c%e6%97%b6%ef%bc%8cmysql-%e6%9f%a5%e8%af%a2%e5%9c%a8-php-%e4%b8%ad","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/207410\/","title":{"rendered":"\u5f53\u5728\u4ee3\u7801\u4e2d\u4f5c\u4e3a\u51c6\u5907\u597d\u7684\u8bed\u53e5\u8fd0\u884c\u65f6\uff0cMySQL \u67e5\u8be2\u5728 PHP \u4e2d\u8fd0\u884c\u7f13\u6162\uff0c\u4f46\u901a\u8fc7\u76f4\u63a5 MySQL \u67e5\u8be2\u8fd0\u884c\u901f\u5ea6\u5f88\u5feb"},"content":{"rendered":"<p><b><\/b> <\/p>\n<p>\u5f53\u524d\u4f4d\u7f6e\uff1a <span>&gt;<\/span> <span>&gt;<\/span> <span>&gt;<\/span> <span>&gt;<\/span> <span>\u5f53\u5728\u4ee3\u7801\u4e2d\u4f5c\u4e3a\u51c6\u5907\u597d\u7684\u8bed\u53e5\u8fd0\u884c\u65f6\uff0cMySQL \u67e5\u8be2\u5728 PHP \u4e2d\u8fd0\u884c\u7f13\u6162\uff0c\u4f46\u901a\u8fc7\u76f4\u63a5 MySQL \u67e5\u8be2\u8fd0\u884c\u901f\u5ea6\u5f88\u5feb<\/span><\/p>\n<p><span>\u6765\u6e90\uff1astackoverflow<\/span><br \/>\n<span>2024-04-22 13:00:34<\/span><br \/>\n<span><i><\/i>0\u6d4f\u89c8<\/span><br \/>\n<span style=\"cursor: pointer\"><i><\/i>\u6536\u85cf<\/span> <\/p>\n<p>\u672c\u7bc7\u6587\u7ae0\u4e3b\u8981\u662f\u7ed3\u5408\u6211\u4e4b\u524d\u9762\u8bd5\u7684\u5404\u79cd\u7ecf\u5386\u548c\u5b9e\u6218\u5f00\u53d1\u4e2d\u9047\u5230\u7684\u95ee\u9898\u89e3\u51b3\u7ecf\u9a8c\u6574\u7406\u7684\uff0c\u5e0c\u671b\u8fd9\u7bc7\u300a\u5f53\u5728\u4ee3\u7801\u4e2d\u4f5c\u4e3a\u51c6\u5907\u597d\u7684\u8bed\u53e5\u8fd0\u884c\u65f6\uff0cMySQL \u67e5\u8be2\u5728 PHP \u4e2d\u8fd0\u884c\u7f13\u6162\uff0c\u4f46\u901a\u8fc7\u76f4\u63a5 MySQL \u67e5\u8be2\u8fd0\u884c\u901f\u5ea6\u5f88\u5feb\u300b\u5bf9\u4f60\u6709\u5f88\u5927\u5e2e\u52a9\uff01\u6b22\u8fce\u6536\u85cf\uff0c\u5206\u4eab\u7ed9\u66f4\u591a\u7684\u9700\u8981\u7684\u670b\u53cb\u5b66\u4e60~<\/p>\n<p> \u95ee\u9898\u5185\u5bb9<br \/>\n <\/p>\n<p>\u6211\u8bd5\u56fe\u8c03\u8bd5\u7684\u4e00\u4e2a PHP \u5e94\u7528\u7a0b\u5e8f\u5728\u4e00\u4e2a\u66f4\u5927\u7684 MySQL \u6570\u636e\u5e93\u4e0a\u8fd0\u884c\u4e86\u51e0\u4e2a\u8bbe\u8ba1\u7cdf\u7cd5\u7684\u67e5\u8be2\u3002<\/p>\n<p>\u6709\u51e0\u4e2a\u9875\u9762\u771f\u7684\u5f88\u6162\uff0c\u7ed3\u679c\u53d1\u73b0\u8fd9\u662f\u56e0\u4e3a\u4e00\u4e9b\u67e5\u8be2\u3002\u6211\u5f00\u59cb\u4e00\u4e00\u68c0\u67e5\u6bcf\u4e2a\u67e5\u8be2\uff0c\u867d\u7136\u5b83\u4eec\u5f88\u6162\uff0c\u4f46\u5b83\u4eec\u672c\u8eab\u5e76\u6ca1\u6709\u90a3\u4e48\u6162\u3002<\/p>\n<p>\u7ecf\u8fc7\u8fdb\u4e00\u6b65\u8c03\u8bd5\u540e\u53d1\u73b0\uff0c\u53ea\u6709\u5f53\u5e94\u7528\u7a0b\u5e8f\u5c06\u5b83\u4eec\u4f5c\u4e3a\u51c6\u5907\u597d\u7684\u8bed\u53e5\u8fd0\u884c\u65f6\uff0c\u5b83\u4eec\u624d\u4f1a\u53d8\u6162\u3002<\/p>\n<ul>\n<li>\u5982\u679c\u6211\u901a\u8fc7 MySQL \u5ba2\u6237\u7aef\u624b\u52a8\u8fd0\u884c\u67e5\u8be2\uff0c\u5927\u7ea6\u9700\u8981 300 \u6beb\u79d2\u3002\u5982\u679c\u6211\u901a\u8fc7My\u200b\u200bSQL\u5ba2\u6237\u7aef\u521b\u5efa\u4e00\u4e2a\u51c6\u5907\u597d\u7684\u8bed\u53e5\u5e76\u8bbe\u7f6e\u53c2\u6570\u5e76\u8fd0\u884c\u5b83\uff0c\u5927\u7ea6\u9700\u8981300\u6beb\u79d2\u3002<\/li>\n<li>\u5982\u679c\u6211\u4ece PHP (mysqli) \u8fd0\u884c\u7b80\u5355\u67e5\u8be2\uff0c\u5927\u7ea6\u9700\u8981 300 \u6beb\u79d2\u3002<\/li>\n<li>\u5982\u679c\u6211\u50cf\u5e94\u7528\u7a0b\u5e8f\u90a3\u6837\u8fd0\u884c\u5b83\uff08\u901a\u8fc7 <code>mysqli<\/code>\uff09\u4f5c\u4e3a\u51c6\u5907\u597d\u7684\u8bed\u53e5\uff0c\u5219\u9700\u8981 100 \u79d2\u3002<\/li>\n<\/ul>\n<p>\u6211\u60f3\u53ef\u80fd\u662f<code>mysqli<\/code>\u6240\u4ee5\u6211\u7528PDO\u5c1d\u8bd5\u4e86\u4e00\u4e0b\uff0c\u7ed3\u679c\u662f\u4e00\u6837\u7684\u3002\u5c1d\u8bd5\u4e86\u4e0d\u540c\u7684 PHP \u7248\u672c\uff085.6\u30017.2\u30017.3\uff09\u5e76\u5f97\u5230\u76f8\u540c\u7684\u7ed3\u679c\u3002<\/p>\n<p>\u6240\u4ee5\u6211\u7ed9\u4e86\u6700\u540e\u4e00\u6b21\u673a\u4f1a\uff0c\u7f16\u5199\u4e86\u4e00\u4e2a\u5c0f\u7684 Go \u811a\u672c\u6765\u6d4b\u8bd5\uff0c\u6211\u5f97\u5230\u4e86\u76f8\u540c\u7684\u7ed3\u679c\uff0c\u5e76\u4e14\u4e8b\u60c5\u5f97\u5230\u4e86\u6539\u8fdb\u3002<\/p>\n<p>\u73b0\u5728\uff0c\u5982\u679c\u6211\u4ece MySQL \u5ba2\u6237\u7aef\u3001MySQL Workbench \u6216 PHPStorms \u6570\u636e\u5e93\u5ba2\u6237\u7aef\u8fd0\u884c\u67e5\u8be2\u7684\u9884\u51c6\u5907\u8bed\u53e5\u7248\u672c\uff0c\u901f\u5ea6\u4f1a\u5f88\u5feb\u3002\u5982\u679c\u6211\u4ece\u4ee3\u7801\u8fd0\u884c\u67e5\u8be2\uff0c\u901f\u5ea6\u4f1a\u975e\u5e38\u5feb\u3002<\/p>\n<p>\u5982\u679c\u6211\u80fd\u63d0\u4f9b\u6709\u5173\u6211\u5e94\u8be5\u6ce8\u610f\u4ec0\u4e48\u3001\u6211\u5e94\u8be5\u5728\u54ea\u91cc\u7ee7\u7eed\u8c03\u8bd5\u7684\u5e2e\u52a9\uff0c\u6211\u4eec\u5c06\u4e0d\u80dc\u611f\u6fc0\u3002<\/p>\n<p> <\/p>\n<h2>\u89e3\u51b3\u65b9\u6848<\/h2>\n<p> <\/p>\n<p>\u4e8b\u5b9e\u8bc1\u660e\uff0c\u8fd9\u662f\u7531\u7565\u6709\u4e0d\u540c\u7684\u6267\u884c\u8ba1\u5212\u5f15\u8d77\u7684\u3002 MySQL\u4f3c\u4e4e\u7eaf\u7cb9\u57fa\u4e8e\u8bed\u53e5\u521b\u5efa\u6267\u884c\u8ba1\u5212\uff0c\u4e0d\u5305\u62ec\u901a\u8fc7 <code>mysqli<\/code> \u6216 <code>PDO<\/code> \u4f7f\u7528\u51c6\u5907\u597d\u7684\u8bed\u53e5\u65f6\u7684\u53c2\u6570\u503c\uff0c\u8fd9\u662f\u6709\u9053\u7406\u7684\u3002\u7136\u800c\uff0c\u5f53\u5b83\u63d0\u4f9b\u5b8c\u6574\u7684\u67e5\u8be2\u65f6\uff0c\u5728\u6211\u4eec\u7684\u4f8b\u5b50\u4e2d\uff0c\u5b83\u5f15\u5165\u4e86\u5bf9\u5176\u4e2d\u4e00\u4e2a\u8868\u7684\u4f18\u5316\uff0c\u8fd9\u4ea7\u751f\u4e86\u5de8\u5927\u7684\u5dee\u5f02\u3002<\/p>\n<p>\u5176\u4e2d\u4e00\u4e2a\u8868\uff08\u5305\u542b 550 \u4e07\u884c\uff09\u5728\u4f7f\u7528\u975e\u51c6\u5907\u8bed\u53e5\u8fd0\u884c\u65f6\u5177\u6709 <code>Using join buffer (Block Nested Loop)<\/code> Extra\uff0c\u800c\u4f7f\u7528\u51c6\u5907\u8bed\u53e5\u5219\u6ca1\u6709\u3002\u8fd9\u4f3c\u4e4e\u4e3a\u6211\u4eec\u5e26\u6765\u4e86\u8fd1 1000 \u500d\u7684\u6027\u80fd\u5dee\u5f02\u3002<\/p>\n<p>\u6211\u4ecd\u7136\u4e0d\u786e\u5b9a\u4e3a\u4ec0\u4e48\u8fd9\u901a\u8fc7 PHPStorm \u6216 CLI <code>mysql<\/code> \u5ba2\u6237\u7aef\u6ca1\u6709\u95ee\u9898\uff0c\u6211\u6700\u597d\u7684\u731c\u6d4b\u662f\uff0cMySQL \u4e2d\u7684\u67d0\u4e9b API \u671f\u671b\u5728\u51c6\u5907\u8bed\u53e5\u65f6\u6267\u884c\u8ba1\u5212\u5b8c\u6210\uff0c\u800c\u5176\u4ed6 API \u548cCLI \u5ba2\u6237\u7aef\u5219\u4e0d\u7136\u3002<\/p>\n<p>\u7406\u8bba\u8981\u638c\u63e1\uff0c\u5b9e\u64cd\u4e0d\u80fd\u843d\uff01\u4ee5\u4e0a\u5173\u4e8e\u300a\u5f53\u5728\u4ee3\u7801\u4e2d\u4f5c\u4e3a\u51c6\u5907\u597d\u7684\u8bed\u53e5\u8fd0\u884c\u65f6\uff0cMySQL \u67e5\u8be2\u5728 PHP \u4e2d\u8fd0\u884c\u7f13\u6162\uff0c\u4f46\u901a\u8fc7\u76f4\u63a5 MySQL \u67e5\u8be2\u8fd0\u884c\u901f\u5ea6\u5f88\u5feb\u300b\u7684\u8be6\u7ec6\u4ecb\u7ecd\uff0c\u5927\u5bb6\u90fd\u638c\u63e1\u4e86\u5427\uff01\u5982\u679c\u60f3\u8981\u7ee7\u7eed\u63d0\u5347\u81ea\u5df1\u7684\u80fd\u529b\uff0c\u90a3\u4e48\u5c31\u6765\u5173\u6ce8\u516c\u4f17\u53f7\u5427\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5f53\u524d\u4f4d\u7f6e\uff1a &gt; &gt; &#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4925],"tags":[],"class_list":["post-207410","post","type-post","status-publish","format-standard","hentry","category-4925"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/207410","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=207410"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/207410\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=207410"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=207410"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=207410"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}