{"id":51150,"date":"2025-08-10T18:14:58","date_gmt":"2025-08-10T10:14:58","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/51150.html"},"modified":"2025-08-10T18:14:58","modified_gmt":"2025-08-10T10:14:58","slug":"%e8%81%94%e5%90%88%e7%b4%a2%e5%bc%95%e5%85%a8%e8%a7%a3%e6%9e%90%ef%bc%9a%e4%b8%80%e6%a3%b5%e6%a0%91%ef%bc%8c%e6%92%91%e8%b5%b7%e6%9f%a5%e8%af%a2%e7%9a%84%e5%8d%8a%e8%be%b9%e5%a4%a9","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/51150.html","title":{"rendered":"\u8054\u5408\u7d22\u5f15\u5168\u89e3\u6790\uff1a\u4e00\u68f5\u6811\uff0c\u6491\u8d77\u67e5\u8be2\u7684\u534a\u8fb9\u5929"},"content":{"rendered":"<p id=\"main-toc\">\u76ee\u5f55<\/p>\n<p id=\"%E4%B8%80%E3%80%81%E4%B8%BA%E4%BB%80%E4%B9%88%E8%81%94%E5%90%88%E7%B4%A2%E5%BC%95%E6%98%AFMySQL%E6%80%A7%E8%83%BD%E4%BC%98%E5%8C%96%E7%9A%84%E2%80%9C%E7%8E%8B%E7%89%8C%E2%80%9D%EF%BC%9F-toc\" style=\"margin-left:0px\">\u4e00\u3001\u4e3a\u4ec0\u4e48\u8054\u5408\u7d22\u5f15\u662fMySQL\u6027\u80fd\u4f18\u5316\u7684\u201c\u738b\u724c\u201d&#xff1f;<\/p>\n<p id=\"%EF%BC%88%E4%B8%80%EF%BC%89%E7%B4%A2%E5%BC%95%E7%9A%84%E5%9F%BA%E6%9C%AC%E7%BB%93%E6%9E%84%EF%BC%9A%E4%BB%8E%E8%81%9A%E7%B0%87%E5%88%B0%E9%9D%9E%E8%81%9A%E7%B0%87-toc\" style=\"margin-left:40px\">&#xff08;\u4e00&#xff09;\u7d22\u5f15\u7684\u57fa\u672c\u7ed3\u6784&#xff1a;\u4ece\u805a\u7c07\u5230\u975e\u805a\u7c07<\/p>\n<p id=\"1.%20%E8%81%9A%E7%B0%87%E7%B4%A2%E5%BC%95%EF%BC%88Clustered%20Index%EF%BC%89-toc\" style=\"margin-left:80px\">1. \u805a\u7c07\u7d22\u5f15&#xff08;Clustered Index&#xff09;<\/p>\n<p id=\"2.%20%E9%9D%9E%E8%81%9A%E7%B0%87%E7%B4%A2%E5%BC%95%EF%BC%88Secondary%20Index%EF%BC%89-toc\" style=\"margin-left:80px\">2. \u975e\u805a\u7c07\u7d22\u5f15&#xff08;Secondary Index&#xff09;<\/p>\n<p id=\"%EF%BC%88%E4%BA%8C%EF%BC%89%E4%B8%8D%E5%90%8C%E7%B4%A2%E5%BC%95%E7%9A%84%E9%80%82%E7%94%A8%E5%9C%BA%E6%99%AF%E4%B8%80%E8%A7%88-toc\" style=\"margin-left:40px\">&#xff08;\u4e8c&#xff09;\u4e0d\u540c\u7d22\u5f15\u7684\u9002\u7528\u573a\u666f\u4e00\u89c8<\/p>\n<p id=\"%EF%BC%88%E4%B8%89%EF%BC%89%E8%81%94%E5%90%88%E7%B4%A2%E5%BC%95%E7%9A%84%E7%99%BB%E5%9C%BA%EF%BC%9A%E4%B8%BA%E4%BB%80%E4%B9%88%E5%AE%83%E6%98%AF%E6%85%A2%20SQL%20%E7%9A%84%E8%A7%A3%E8%8D%AF%EF%BC%9F-toc\" style=\"margin-left:40px\">&#xff08;\u4e09&#xff09;\u8054\u5408\u7d22\u5f15\u7684\u767b\u573a&#xff1a;\u4e3a\u4ec0\u4e48\u5b83\u662f\u6162 SQL \u7684\u89e3\u836f&#xff1f;<\/p>\n<p id=\"%E4%BA%8C%E3%80%81%E8%81%94%E5%90%88%E7%B4%A2%E5%BC%95%E7%9A%84%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84%E6%8E%A2%E7%A9%B6-toc\" style=\"margin-left:0px\">\u4e8c\u3001\u8054\u5408\u7d22\u5f15\u7684\u6570\u636e\u7ed3\u6784\u63a2\u7a76<\/p>\n<p id=\"%EF%BC%88%E4%B8%80%EF%BC%89%E8%81%94%E5%90%88%E7%B4%A2%E5%BC%95%E7%9A%84%E5%9F%BA%E6%9C%AC%E7%BB%93%E6%9E%84-toc\" style=\"margin-left:40px\">&#xff08;\u4e00&#xff09;\u8054\u5408\u7d22\u5f15\u7684\u57fa\u672c\u7ed3\u6784<\/p>\n<p id=\"1.%20%E7%B4%A2%E5%BC%95%E5%AD%98%E5%82%A8%E7%BB%93%E6%9E%84-toc\" style=\"margin-left:80px\">1. \u7d22\u5f15\u5b58\u50a8\u7ed3\u6784<\/p>\n<p id=\"1.1%20%E5%B1%80%E9%83%A8%E9%A2%84%E8%AF%BB%E6%80%A7%E5%8E%9F%E7%90%86-toc\" style=\"margin-left:120px\">1.1 \u5c40\u90e8\u9884\u8bfb\u6027\u539f\u7406<\/p>\n<p id=\"%E4%B8%BA%E4%BB%80%E4%B9%88%E8%BF%99%E6%A0%B7%E5%81%9A%EF%BC%9F-toc\" style=\"margin-left:160px\">\u4e3a\u4ec0\u4e48\u8fd9\u6837\u505a&#xff1f;<\/p>\n<p id=\"2.%20%F0%9F%93%A6%20InnoDB%20%E7%9A%84%E9%A1%B5%EF%BC%88Page%EF%BC%89%EF%BC%9A%E5%AD%98%E5%82%A8%E7%9A%84%E6%9C%80%E5%B0%8F%E5%8D%95%E5%85%83-toc\" style=\"margin-left:80px\">2. &#x1f4e6; InnoDB \u7684\u9875&#xff08;Page&#xff09;&#xff1a;\u5b58\u50a8\u7684\u6700\u5c0f\u5355\u5143<\/p>\n<p id=\"2.1%20%E9%A1%B5%E9%9D%A2%E5%88%86%E9%85%8D%E8%BF%87%E7%A8%8B-toc\" style=\"margin-left:120px\">2.1 \u9875\u9762\u5206\u914d\u8fc7\u7a0b<\/p>\n<p id=\"2.2%20%F0%9F%A7%AC%20%E9%A1%B5%E7%9A%84%E7%B1%BB%E5%9E%8B-toc\" style=\"margin-left:120px\">2.2 &#x1f9ec; \u9875\u7684\u7c7b\u578b<\/p>\n<p id=\"2.3%20%F0%9F%A7%B1%20%E9%A1%B5%EF%BC%88Page%EF%BC%89%E7%9A%84%E5%86%85%E9%83%A8%E7%BB%93%E6%9E%84%EF%BC%9A%E4%B8%89%E6%AE%B5%E5%BC%8F%E5%B8%83%E5%B1%80-toc\" style=\"margin-left:120px\">2.3 &#x1f9f1; \u9875&#xff08;Page&#xff09;\u7684\u5185\u90e8\u7ed3\u6784&#xff1a;\u4e09\u6bb5\u5f0f\u5e03\u5c40<\/p>\n<p id=\"%E2%9C%8F%EF%B8%8F%20%E5%85%B7%E4%BD%93%E8%AF%B4%E6%98%8E-toc\" style=\"margin-left:120px\">\u270f\ufe0f \u5177\u4f53\u8bf4\u660e<\/p>\n<p id=\"3.%20%E8%81%9A%E7%B0%87%E7%B4%A2%E5%BC%95%20vs%20%E9%9D%9E%E8%81%9A%E7%B0%87%E7%B4%A2%E5%BC%95%E7%9A%84%E5%8F%B6%E5%AD%90%E8%8A%82%E7%82%B9%E8%AE%BF%E9%97%AE%E7%BB%93%E6%9E%84-toc\" style=\"margin-left:80px\">3. \u805a\u7c07\u7d22\u5f15 vs \u975e\u805a\u7c07\u7d22\u5f15\u7684\u53f6\u5b50\u8282\u70b9\u8bbf\u95ee\u7ed3\u6784<\/p>\n<p id=\"3.1%20%F0%9F%94%B7%20%E8%81%9A%E7%B0%87%E7%B4%A2%E5%BC%95%EF%BC%88Clustered%20Index%EF%BC%89%E7%9A%84%E5%8F%B6%E5%AD%90%E8%8A%82%E7%82%B9%E8%AE%BF%E9%97%AE%E7%BB%93%E6%9E%84-toc\" style=\"margin-left:120px\">3.1 &#x1f537; \u805a\u7c07\u7d22\u5f15&#xff08;Clustered Index&#xff09;\u7684\u53f6\u5b50\u8282\u70b9\u8bbf\u95ee\u7ed3\u6784<\/p>\n<p id=\"%E2%9C%85%20%E9%A1%B5%E9%9D%A2%E8%AE%BF%E9%97%AE%E7%BB%93%E6%9E%84%E7%89%B9%E7%82%B9-toc\" style=\"margin-left:160px\">\u2705 \u9875\u9762\u8bbf\u95ee\u7ed3\u6784\u7279\u70b9<\/p>\n<p id=\"%E2%9C%85%20%E4%BC%98%E5%8A%BF-toc\" style=\"margin-left:160px\">\u2705 \u4f18\u52bf<\/p>\n<p id=\"%F0%9F%93%8C%20%E7%BB%93%E6%9E%84%E5%9B%BE%E7%A4%BA%E6%84%8F%EF%BC%9A-toc\" style=\"margin-left:160px\">&#x1f4cc; \u7ed3\u6784\u56fe\u793a\u610f&#xff1a;<\/p>\n<p id=\"3.2%20%F0%9F%94%B7%20%E9%9D%9E%E8%81%9A%E7%B0%87%E7%B4%A2%E5%BC%95%EF%BC%88Secondary%20Index%EF%BC%89%E7%9A%84%E5%8F%B6%E5%AD%90%E8%8A%82%E7%82%B9%E8%AE%BF%E9%97%AE%E7%BB%93%E6%9E%84-toc\" style=\"margin-left:120px\">3.2 &#x1f537; \u975e\u805a\u7c07\u7d22\u5f15&#xff08;Secondary Index&#xff09;\u7684\u53f6\u5b50\u8282\u70b9\u8bbf\u95ee\u7ed3\u6784<\/p>\n<p id=\"%E2%9C%85%20%E9%A1%B5%E9%9D%A2%E8%AE%BF%E9%97%AE%E7%BB%93%E6%9E%84%E7%89%B9%E7%82%B9-toc\" style=\"margin-left:160px\">\u2705 \u9875\u9762\u8bbf\u95ee\u7ed3\u6784\u7279\u70b9<\/p>\n<p id=\"%E2%9C%85%20%E7%89%B9%E7%82%B9%E4%B8%8E%E5%BD%B1%E5%93%8D-toc\" style=\"margin-left:160px\">\u2705 \u7279\u70b9\u4e0e\u5f71\u54cd<\/p>\n<p id=\"%F0%9F%93%8C%20%E7%BB%93%E6%9E%84%E5%9B%BE%E7%A4%BA%E6%84%8F-toc\" style=\"margin-left:160px\">&#x1f4cc; \u7ed3\u6784\u56fe\u793a\u610f<\/p>\n<p id=\"3.3%20%F0%9F%94%8D%20%E8%81%9A%E7%B0%87%E7%B4%A2%E5%BC%95%20vs%20%E9%9D%9E%E8%81%9A%E7%B0%87%E7%B4%A2%E5%BC%95%20%E8%AE%BF%E9%97%AE%E7%BB%93%E6%9E%84%E5%AF%B9%E6%AF%94%E6%80%BB%E7%BB%93-toc\" style=\"margin-left:120px\">3.3 &#x1f50d; \u805a\u7c07\u7d22\u5f15 vs \u975e\u805a\u7c07\u7d22\u5f15 \u8bbf\u95ee\u7ed3\u6784\u5bf9\u6bd4\u603b\u7ed3<\/p>\n<p id=\"%EF%BC%88%E4%BA%8C%EF%BC%89B%2B%E6%A0%91%E7%BB%93%E6%9E%84-toc\" style=\"margin-left:40px\">&#xff08;\u4e8c&#xff09;B&#043;\u6811\u7ed3\u6784<\/p>\n<p id=\"1.%20B%2B%E6%A0%91%E7%AE%80%E4%BB%8B-toc\" style=\"margin-left:80px\">1. B&#043;\u6811\u7b80\u4ecb<\/p>\n<p id=\"2.%20%E8%81%9A%E7%B0%87%E7%B4%A2%E5%BC%95%E4%B8%AD%E7%9A%84%20B%2B%E6%A0%91-toc\" style=\"margin-left:80px\">2. \u805a\u7c07\u7d22\u5f15\u4e2d\u7684 B&#043;\u6811<\/p>\n<p id=\"2.1%20B%2B%E6%A0%91%E8%AE%BF%E9%97%AE%E8%BF%87%E7%A8%8B%E4%B8%8E%E5%86%85%E5%AD%98%E9%A1%B5%E5%8A%A0%E8%BD%BD%E6%9C%BA%E5%88%B6-toc\" style=\"margin-left:120px\">2.1 B&#043;\u6811\u8bbf\u95ee\u8fc7\u7a0b\u4e0e\u5185\u5b58\u9875\u52a0\u8f7d\u673a\u5236<\/p>\n<p id=\"2.2%20%E5%90%AF%E5%8A%A8%E5%8A%A0%E8%BD%BD%E4%B8%8E%E7%BC%93%E5%AD%98%E9%A9%BB%E7%95%99-toc\" style=\"margin-left:120px\">2.2 \u542f\u52a8\u52a0\u8f7d\u4e0e\u7f13\u5b58\u9a7b\u7559<\/p>\n<p id=\"2.3%20%E5%8F%8C%E5%90%91%E9%93%BE%E8%A1%A8%E4%B8%8E%E8%8C%83%E5%9B%B4%E6%9F%A5%E8%AF%A2%E4%BC%98%E5%8C%96-toc\" style=\"margin-left:120px\">2.3 \u53cc\u5411\u94fe\u8868\u4e0e\u8303\u56f4\u67e5\u8be2\u4f18\u5316<\/p>\n<p id=\"3.%20%E9%9D%9E%E8%81%9A%E7%B0%87%E7%B4%A2%E5%BC%95%E4%B8%AD%E7%9A%84%20B%2B%E6%A0%91-toc\" style=\"margin-left:80px\">3. \u975e\u805a\u7c07\u7d22\u5f15\u4e2d\u7684 B&#043;\u6811<\/p>\n<p id=\"%EF%BC%88%E4%B8%89%EF%BC%89%E8%81%94%E5%90%88%E7%B4%A2%E5%BC%95B%2B%E6%A0%91%E7%BB%93%E6%9E%84-toc\" style=\"margin-left:40px\">&#xff08;\u4e09&#xff09;\u8054\u5408\u7d22\u5f15B&#043;\u6811\u7ed3\u6784<\/p>\n<p id=\"1.%20%F0%9F%8C%90%20%E8%81%94%E5%90%88%E7%B4%A2%E5%BC%95%E7%9A%84%E5%BA%95%E5%B1%82%E7%BB%93%E6%9E%84%E4%B8%8E%E8%AE%BE%E8%AE%A1%E6%B3%A8%E6%84%8F%E4%BA%8B%E9%A1%B9-toc\" style=\"margin-left:80px\">1. &#x1f310; \u8054\u5408\u7d22\u5f15\u7684\u5e95\u5c42\u7ed3\u6784\u4e0e\u8bbe\u8ba1\u6ce8\u610f\u4e8b\u9879<\/p>\n<p id=\"2.%20%F0%9F%94%8D%20%E8%81%94%E5%90%88%E7%B4%A2%E5%BC%95%E7%9A%84%E9%81%8D%E5%8E%86%E9%80%BB%E8%BE%91%EF%BC%9A%E6%9C%80%E5%B7%A6%E5%89%8D%E7%BC%80%E5%8E%9F%E5%88%99-toc\" style=\"margin-left:80px\">2. &#x1f50d; \u8054\u5408\u7d22\u5f15\u7684\u904d\u5386\u903b\u8f91&#xff1a;\u6700\u5de6\u524d\u7f00\u539f\u5219<\/p>\n<p id=\"3.%20%F0%9F%93%A6%20%E7%A3%81%E7%9B%98%E9%A1%B5%E7%BB%93%E6%9E%84%E5%AF%B9%E7%B4%A2%E5%BC%95%E6%80%A7%E8%83%BD%E7%9A%84%E5%BD%B1%E5%93%8D-toc\" style=\"margin-left:80px\">3. &#x1f4e6; \u78c1\u76d8\u9875\u7ed3\u6784\u5bf9\u7d22\u5f15\u6027\u80fd\u7684\u5f71\u54cd<\/p>\n<p id=\"4.%20%F0%9F%A7%A0%20%E4%B8%9A%E5%8A%A1%E5%9C%BA%E6%99%AF%E5%90%AF%E7%A4%BA-toc\" style=\"margin-left:80px\">4. &#x1f9e0; \u4e1a\u52a1\u573a\u666f\u542f\u793a<\/p>\n<p id=\"%E4%B8%89%E3%80%81%E8%81%94%E5%90%88%E7%B4%A2%E5%BC%95%E7%9A%84%E5%8E%9F%E7%90%86%E4%B8%8E%E4%BC%98%E5%8C%96%E6%9C%BA%E5%88%B6-toc\" style=\"margin-left:0px\">\u4e09\u3001\u8054\u5408\u7d22\u5f15\u7684\u539f\u7406\u4e0e\u4f18\u5316\u673a\u5236<\/p>\n<p id=\"%EF%BC%88%E4%B8%80%EF%BC%89%E9%98%B2%E6%AD%A2%E7%B4%A2%E5%BC%95%E7%AD%96%E7%95%A5%E5%B9%B2%E6%89%B0%EF%BC%9A%E8%81%94%E5%90%88%E7%B4%A2%E5%BC%95%E4%B8%BA%E4%BD%95%E6%9B%B4%E7%A8%B3%E5%AE%9A%E5%8F%AF%E9%9D%A0-toc\" style=\"margin-left:40px\">&#xff08;\u4e00&#xff09;\u9632\u6b62\u7d22\u5f15\u7b56\u7565\u5e72\u6270&#xff1a;\u8054\u5408\u7d22\u5f15\u4e3a\u4f55\u66f4\u7a33\u5b9a\u53ef\u9760<\/p>\n<p id=\"1.%20%E2%9C%85%20%E7%A4%BA%E4%BE%8B%E5%AF%B9%E6%AF%94%E5%88%86%E6%9E%90-toc\" style=\"margin-left:80px\">1. \u2705 \u793a\u4f8b\u5bf9\u6bd4\u5206\u6790<\/p>\n<p id=\"1.1%20%E6%83%85%E5%86%B5%E4%B8%80%EF%BC%9A%E4%BD%BF%E7%94%A8%E5%A4%9A%E4%B8%AA%E5%8D%95%E5%88%97%E7%B4%A2%E5%BC%95-toc\" style=\"margin-left:120px\">1.1 \u60c5\u51b5\u4e00&#xff1a;\u4f7f\u7528\u591a\u4e2a\u5355\u5217\u7d22\u5f15<\/p>\n<p id=\"1.2%20%E6%83%85%E5%86%B5%E4%BA%8C%EF%BC%9A%E4%BD%BF%E7%94%A8%E8%81%94%E5%90%88%E7%B4%A2%E5%BC%95%20(name%2C%20age)-toc\" style=\"margin-left:120px\">1.2 \u60c5\u51b5\u4e8c&#xff1a;\u4f7f\u7528\u8054\u5408\u7d22\u5f15 (name, age)<\/p>\n<p id=\"2.%20%E2%9C%85%20%E4%B8%93%E4%B8%9A%E6%80%BB%E7%BB%93%EF%BC%9A%E4%B8%BA%E4%BD%95%E8%81%94%E5%90%88%E7%B4%A2%E5%BC%95%E8%83%BD%E8%A7%84%E9%81%BF%E7%AD%96%E7%95%A5%E5%B9%B2%E6%89%B0%EF%BC%9F-toc\" style=\"margin-left:80px\">2. \u2705 \u4e13\u4e1a\u603b\u7ed3&#xff1a;\u4e3a\u4f55\u8054\u5408\u7d22\u5f15\u80fd\u89c4\u907f\u7b56\u7565\u5e72\u6270&#xff1f;<\/p>\n<p id=\"%E2%9C%85%20%E5%B0%8F%E8%B4%B4%E5%A3%AB%EF%BC%9A%E4%BB%80%E4%B9%88%E6%98%AF%E7%B4%A2%E5%BC%95%E9%80%89%E6%8B%A9%E6%80%A7%EF%BC%9F-toc\" style=\"margin-left:160px\">\u2705 \u5c0f\u8d34\u58eb&#xff1a;\u4ec0\u4e48\u662f\u7d22\u5f15\u9009\u62e9\u6027&#xff1f;<\/p>\n<p id=\"3.%20%E2%9C%85%20%E5%AE%9E%E8%B7%B5%E5%BB%BA%E8%AE%AE-toc\" style=\"margin-left:80px\">3. \u2705 \u5b9e\u8df5\u5efa\u8bae<\/p>\n<p id=\"%EF%BC%88%E4%BA%8C%EF%BC%89%E7%B4%A2%E5%BC%95%E8%A6%86%E7%9B%96%E4%B8%8E%E6%9F%A5%E8%AF%A2%E4%BC%98%E5%8C%96%EF%BC%9A%E6%8F%90%E9%AB%98%E6%9F%A5%E8%AF%A2%E6%95%88%E7%8E%87-toc\" style=\"margin-left:40px\">&#xff08;\u4e8c&#xff09;\u7d22\u5f15\u8986\u76d6\u4e0e\u67e5\u8be2\u4f18\u5316&#xff1a;\u63d0\u9ad8\u67e5\u8be2\u6548\u7387<\/p>\n<p id=\"1.%20%E8%81%94%E5%90%88%E7%B4%A2%E5%BC%95%E7%9A%84%E8%A6%86%E7%9B%96%E8%83%BD%E5%8A%9B%EF%BC%9A%E9%81%BF%E5%85%8D%E5%9B%9E%E8%A1%A8-toc\" style=\"margin-left:80px\">1. \u8054\u5408\u7d22\u5f15\u7684\u8986\u76d6\u80fd\u529b&#xff1a;\u907f\u514d\u56de\u8868<\/p>\n<p id=\"2.%20%E5%AE%9E%E8%B7%B5%E4%B8%AD%E7%9A%84%E5%BA%94%E7%94%A8%EF%BC%9A%E5%A6%82%E4%BD%95%E8%AE%BE%E8%AE%A1%E5%90%88%E9%80%82%E7%9A%84%E8%81%94%E5%90%88%E7%B4%A2%E5%BC%95-toc\" style=\"margin-left:80px\">2. \u5b9e\u8df5\u4e2d\u7684\u5e94\u7528&#xff1a;\u5982\u4f55\u8bbe\u8ba1\u5408\u9002\u7684\u8054\u5408\u7d22\u5f15<\/p>\n<p id=\"a.%20%E7%A1%AE%E4%BF%9D%E7%B4%A2%E5%BC%95%E8%A6%86%E7%9B%96%E6%89%80%E6%9C%89%E6%9F%A5%E8%AF%A2%E5%AD%97%E6%AE%B5-toc\" style=\"margin-left:120px\">a. \u786e\u4fdd\u7d22\u5f15\u8986\u76d6\u6240\u6709\u67e5\u8be2\u5b57\u6bb5<\/p>\n<p id=\"b.%20%E8%80%83%E8%99%91%E6%9C%80%E5%B7%A6%E5%89%8D%E7%BC%80%E5%8E%9F%E5%88%99-toc\" style=\"margin-left:120px\">b. \u8003\u8651\u6700\u5de6\u524d\u7f00\u539f\u5219<\/p>\n<p id=\"c.%20%E9%81%BF%E5%85%8D%E5%86%97%E4%BD%99%E7%9A%84%E7%B4%A2%E5%BC%95%E8%AE%BE%E8%AE%A1-toc\" style=\"margin-left:120px\">c. \u907f\u514d\u5197\u4f59\u7684\u7d22\u5f15\u8bbe\u8ba1<\/p>\n<p id=\"d.%20%E9%81%BF%E5%85%8D%E5%9C%A8%E8%81%94%E5%90%88%E7%B4%A2%E5%BC%95%E4%B8%AD%E4%BD%BF%E7%94%A8%E8%BE%83%E5%A4%A7%E5%AD%97%E6%AE%B5-toc\" style=\"margin-left:120px\">d. \u907f\u514d\u5728\u8054\u5408\u7d22\u5f15\u4e2d\u4f7f\u7528\u8f83\u5927\u5b57\u6bb5<\/p>\n<p id=\"%EF%BC%88%E4%B8%89%EF%BC%89%E7%B4%A2%E5%BC%95%E4%B8%8B%E6%8E%A8%EF%BC%9A%E6%8F%90%E5%8D%87%E6%9F%A5%E8%AF%A2%E6%95%88%E7%8E%87-toc\" style=\"margin-left:40px\">&#xff08;\u4e09&#xff09;\u7d22\u5f15\u4e0b\u63a8&#xff1a;\u63d0\u5347\u67e5\u8be2\u6548\u7387<\/p>\n<p id=\"1.%20%E4%BB%80%E4%B9%88%E6%98%AF%E7%B4%A2%E5%BC%95%E4%B8%8B%E6%8E%A8%EF%BC%88Index%20Condition%20Pushdown%EF%BC%89%EF%BC%9F-toc\" style=\"margin-left:80px\">1. \u4ec0\u4e48\u662f\u7d22\u5f15\u4e0b\u63a8&#xff08;Index Condition Pushdown&#xff09;&#xff1f;<\/p>\n<p id=\"2.%C2%A0%E7%B4%A2%E5%BC%95%E4%B8%8B%E6%8E%A8%E4%B8%8E%E8%81%94%E5%90%88%E7%B4%A2%E5%BC%95%E7%9A%84%E7%BB%93%E5%90%88-toc\" style=\"margin-left:80px\">2.\u00a0\u7d22\u5f15\u4e0b\u63a8\u4e0e\u8054\u5408\u7d22\u5f15\u7684\u7ed3\u5408<\/p>\n<p id=\"2.1%20%E8%81%94%E5%90%88%E7%B4%A2%E5%BC%95%E4%B8%8E%E7%B4%A2%E5%BC%95%E4%B8%8B%E6%8E%A8%E7%9A%84%E4%BC%98%E5%8A%BF%E7%BB%93%E5%90%88-toc\" style=\"margin-left:120px\">2.1 \u8054\u5408\u7d22\u5f15\u4e0e\u7d22\u5f15\u4e0b\u63a8\u7684\u4f18\u52bf\u7ed3\u5408<\/p>\n<p id=\"2.2%20%E7%A4%BA%E4%BE%8B%E6%BC%94%E7%A4%BA%EF%BC%9A%E8%81%94%E5%90%88%E7%B4%A2%E5%BC%95%E4%B8%8E%E7%B4%A2%E5%BC%95%E4%B8%8B%E6%8E%A8-toc\" style=\"margin-left:120px\">2.2 \u793a\u4f8b\u6f14\u793a&#xff1a;\u8054\u5408\u7d22\u5f15\u4e0e\u7d22\u5f15\u4e0b\u63a8<\/p>\n<p id=\"3.%C2%A0%E7%B4%A2%E5%BC%95%E4%B8%8B%E6%8E%A8%E7%9A%84%E5%B7%A5%E4%BD%9C%E5%8E%9F%E7%90%86%E4%B8%8E%E5%AE%9E%E7%8E%B0-toc\" style=\"margin-left:80px\">3.\u00a0\u7d22\u5f15\u4e0b\u63a8\u7684\u5de5\u4f5c\u539f\u7406\u4e0e\u5b9e\u73b0<\/p>\n<p id=\"3.1%20%E7%B4%A2%E5%BC%95%E4%B8%8B%E6%8E%A8%E5%A6%82%E4%BD%95%E5%87%8F%E5%B0%91%E7%A3%81%E7%9B%98I%2FO-toc\" style=\"margin-left:120px\">3.1 \u7d22\u5f15\u4e0b\u63a8\u5982\u4f55\u51cf\u5c11\u78c1\u76d8I\/O<\/p>\n<p id=\"3.2%20%E6%80%A7%E8%83%BD%E6%8F%90%E5%8D%87%EF%BC%9A%E6%A1%88%E4%BE%8B%E5%88%86%E6%9E%90-toc\" style=\"margin-left:120px\">3.2 \u6027\u80fd\u63d0\u5347&#xff1a;\u6848\u4f8b\u5206\u6790<\/p>\n<p id=\"4.%C2%A0%E5%90%AF%E7%94%A8%E5%92%8C%E6%9F%A5%E7%9C%8B%E7%B4%A2%E5%BC%95%E4%B8%8B%E6%8E%A8%E5%8A%9F%E8%83%BD-toc\" style=\"margin-left:80px\">4.\u00a0\u542f\u7528\u548c\u67e5\u770b\u7d22\u5f15\u4e0b\u63a8\u529f\u80fd<\/p>\n<p id=\"4.1%20%E5%A6%82%E4%BD%95%E5%90%AF%E7%94%A8%E7%B4%A2%E5%BC%95%E4%B8%8B%E6%8E%A8-toc\" style=\"margin-left:120px\">4.1 \u5982\u4f55\u542f\u7528\u7d22\u5f15\u4e0b\u63a8<\/p>\n<p id=\"4.2%20%E9%85%8D%E7%BD%AE%E7%B4%A2%E5%BC%95%E4%B8%8B%E6%8E%A8-toc\" style=\"margin-left:120px\">4.2 \u914d\u7f6e\u7d22\u5f15\u4e0b\u63a8<\/p>\n<p id=\"%E5%9B%9B%E3%80%81%E8%81%94%E5%90%88%E7%B4%A2%E5%BC%95%E7%9A%84%E8%90%BD%E5%9C%B0%E5%AE%9E%E8%B7%B5-toc\" style=\"margin-left:0px\">\u56db\u3001\u8054\u5408\u7d22\u5f15\u7684\u843d\u5730\u5b9e\u8df5<\/p>\n<p id=\"%EF%BC%88%E4%B8%80%EF%BC%89%E8%81%94%E5%90%88%E7%B4%A2%E5%BC%95%E2%80%9C%E6%9C%80%E5%B7%A6%E5%89%8D%E7%BC%80%E2%80%9D%E5%8E%9F%E5%88%99-toc\" style=\"margin-left:40px\">&#xff08;\u4e00&#xff09;\u8054\u5408\u7d22\u5f15\u201c\u6700\u5de6\u524d\u7f00\u201d\u539f\u5219<\/p>\n<p id=\"%EF%BC%88%E4%BA%8C%EF%BC%89%E5%88%A9%E7%94%A8%E8%81%94%E5%90%88%E7%B4%A2%E5%BC%95%E6%9C%89%E6%95%88%E9%81%BF%E5%85%8D%E7%B4%A2%E5%BC%95%E7%AD%96%E7%95%A5%E5%B9%B2%E6%89%B0-toc\" style=\"margin-left:40px\">&#xff08;\u4e8c&#xff09;\u5229\u7528\u8054\u5408\u7d22\u5f15\u6709\u6548\u907f\u514d\u7d22\u5f15\u7b56\u7565\u5e72\u6270<\/p>\n<p id=\"%EF%BC%88%E4%B8%89%EF%BC%89%E6%95%B0%E6%8D%AE%E6%9E%81%E7%AB%AF%E5%88%86%E5%B8%83%E4%B8%8B%E8%81%94%E5%90%88%E7%B4%A2%E5%BC%95%E7%9A%84%E4%BD%9C%E7%94%A8-toc\" style=\"margin-left:40px\">&#xff08;\u4e09&#xff09;\u6570\u636e\u6781\u7aef\u5206\u5e03\u4e0b\u8054\u5408\u7d22\u5f15\u7684\u4f5c\u7528<\/p>\n<p id=\"%EF%BC%88%E5%9B%9B%EF%BC%89%E8%81%9A%E5%90%88%E6%93%8D%E4%BD%9C%E5%9C%BA%E6%99%AF-toc\" style=\"margin-left:40px\">&#xff08;\u56db&#xff09;\u805a\u5408\u64cd\u4f5c\u573a\u666f<\/p>\n<p id=\"%EF%BC%88%E4%BA%94%EF%BC%89%E5%A4%9A%E8%A1%A8%E5%85%B3%E8%81%94%E6%9F%A5%E8%AF%A2-toc\" style=\"margin-left:40px\">&#xff08;\u4e94&#xff09;\u591a\u8868\u5173\u8054\u67e5\u8be2<\/p>\n<p id=\"id-5.1MySQLjoin\u7b97\u6cd5-toc\" style=\"margin-left:80px\">1. MySQL join\u7b97\u6cd5<\/p>\n<p id=\"1%EF%B8%8F%E2%83%A3%20Index%20Nested%20Loop%20Join%EF%BC%88%E7%B4%A2%E5%BC%95%E5%B5%8C%E5%A5%97%E5%BE%AA%E7%8E%AF%E8%BF%9E%E6%8E%A5%EF%BC%89-toc\" style=\"margin-left:120px\">1\ufe0f\u20e3 Index Nested Loop Join&#xff08;\u7d22\u5f15\u5d4c\u5957\u5faa\u73af\u8fde\u63a5&#xff09;<\/p>\n<p id=\"2%EF%B8%8F%E2%83%A3%20Block%20Nested%20Loop%20Join%EF%BC%88%E5%9D%97%E5%B5%8C%E5%A5%97%E5%BE%AA%E7%8E%AF%E8%BF%9E%E6%8E%A5%EF%BC%89-toc\" style=\"margin-left:120px\">2\ufe0f\u20e3 Block Nested Loop Join&#xff08;\u5757\u5d4c\u5957\u5faa\u73af\u8fde\u63a5&#xff09;<\/p>\n<p id=\"id-5.2\u591a\u8868\u67e5\u8be2\u4e2d\u8054\u5408\u7d22\u5f15\u63d0\u5347join\u7b97\u6cd5\u67e5\u8be2\u6548\u7387-toc\" style=\"margin-left:80px\">2. \u591a\u8868\u67e5\u8be2\u4e2d\u8054\u5408\u7d22\u5f15\u63d0\u5347join\u7b97\u6cd5\u67e5\u8be2\u6548\u7387<\/p>\n<p id=\"3.%20%E8%81%94%E5%90%88%E6%9F%A5%E8%AF%A2%E4%B8%AD%E7%9A%84%E6%8E%92%E5%BA%8F%E5%AD%97%E6%AE%B5%E5%AF%B9%E6%89%A7%E8%A1%8C%E8%AE%A1%E5%88%92%E7%9A%84%E5%BD%B1%E5%93%8D%E5%88%86%E6%9E%90-toc\" style=\"margin-left:80px\">3. \u8054\u5408\u67e5\u8be2\u4e2d\u7684\u6392\u5e8f\u5b57\u6bb5\u5bf9\u6267\u884c\u8ba1\u5212\u7684\u5f71\u54cd\u5206\u6790<\/p>\n<p id=\"%E6%9F%A5%E8%AF%A2%E8%AF%AD%E5%8F%A5%20A%EF%BC%88%E6%8C%89%20area.id%20%E6%8E%92%E5%BA%8F%EF%BC%89%EF%BC%9A-toc\" style=\"margin-left:120px\">\u67e5\u8be2\u8bed\u53e5 A&#xff08;\u6309 area.id \u6392\u5e8f&#xff09;&#xff1a;<\/p>\n<p id=\"%E6%9F%A5%E8%AF%A2%E8%AF%AD%E5%8F%A5%20B%EF%BC%88%E6%8C%89%20config.id%20%E6%8E%92%E5%BA%8F%EF%BC%89%EF%BC%9A-toc\" style=\"margin-left:120px\">\u67e5\u8be2\u8bed\u53e5 B&#xff08;\u6309 config.id \u6392\u5e8f&#xff09;&#xff1a;<\/p>\n<p id=\"%F0%9F%8E%AF%20%E5%B0%8F%E7%BB%93-toc\" style=\"margin-left:120px\">&#x1f3af; \u5c0f\u7ed3<\/p>\n<p id=\"%E4%BA%94%E3%80%81%E6%80%BB%E7%BB%93%EF%BC%9A%E8%81%94%E5%90%88%E7%B4%A2%E5%BC%95%EF%BC%8C%E4%B8%8D%E6%AD%A2%E6%98%AF%E2%80%9C%E7%BB%84%E5%90%88%E5%AD%97%E6%AE%B5%E2%80%9D%E8%BF%99%E4%B9%88%E7%AE%80%E5%8D%95-toc\" style=\"margin-left:0px\">\u4e94\u3001\u603b\u7ed3&#xff1a;\u8054\u5408\u7d22\u5f15&#xff0c;\u4e0d\u6b62\u662f\u201c\u7ec4\u5408\u5b57\u6bb5\u201d\u8fd9\u4e48\u7b80\u5355<\/p>\n<hr id=\"hr-toc\" \/>\n<p>\u5e72\u8d27\u5206\u4eab&#xff0c;\u611f\u8c22\u60a8\u7684\u9605\u8bfb&#xff01;<\/p>\n<p>\u4f60\u4ee5\u4e3a\u8054\u5408\u7d22\u5f15\u53ea\u662f\u201c\u591a\u4e2a\u5b57\u6bb5\u6392\u6392\u5750\u201d&#xff1f;\u4e0d&#xff0c;\u5b83\u5176\u5b9e\u662f\u6570\u636e\u5e93\u754c\u7684\u201c\u7279\u79cd\u5175\u5c0f\u961f\u201d\u2014\u2014\u534f\u540c\u4f5c\u6218\u3001\u64c5\u6253\u786c\u4ed7\u3001\u6267\u884c\u7cbe\u51c6&#xff01;\u522b\u770b\u5b83\u4f4e\u8c03&#xff0c;\u5173\u952e\u65f6\u523b\u80fd\u8ba9\u67e5\u8be2\u98de\u8d77\u3001\u6162 SQL \u79d2\u8dea\u3002\u672c\u6587\u5c31\u5e26\u4f60\u62c6\u89e3\u8fd9\u652f\u795e\u79d8\u90e8\u961f\u7684\u6218\u672f\u7f16\u6392&#xff0c;\u770b\u770b\u5b83\u662f\u5982\u4f55\u5728\u4ebf\u7ea7\u6570\u636e\u4e2d\u201c\u4ee5\u4e00\u654c\u767e\u201d\u3002<\/p>\n<h2 id=\"%E4%B8%80%E3%80%81%E4%B8%BA%E4%BB%80%E4%B9%88%E8%81%94%E5%90%88%E7%B4%A2%E5%BC%95%E6%98%AFMySQL%E6%80%A7%E8%83%BD%E4%BC%98%E5%8C%96%E7%9A%84%E2%80%9C%E7%8E%8B%E7%89%8C%E2%80%9D%EF%BC%9F\">\u4e00\u3001\u4e3a\u4ec0\u4e48\u8054\u5408\u7d22\u5f15\u662fMySQL\u6027\u80fd\u4f18\u5316\u7684\u201c\u738b\u724c\u201d&#xff1f;<\/h2>\n<p>\u5728\u65e5\u5e38\u5f00\u53d1\u4e2d&#xff0c;\u53ea\u8981\u63a5\u89e6 MySQL&#xff0c;\u5c31\u7ed5\u4e0d\u5f00\u201c\u7d22\u5f15\u201d\u8fd9\u4e2a\u8bdd\u9898\u3002\u800c\u4e00\u63d0\u5230\u7d22\u5f15&#xff0c;\u5f88\u591a\u4eba\u8111\u5b50\u91cc\u9a6c\u4e0a\u60f3\u5230\u7684\u53ef\u80fd\u662f\u201c\u5efa\u7d22\u5f15\u80fd\u52a0\u901f\u67e5\u8be2\u201d\u3002\u4f46\u73b0\u5b9e\u60c5\u51b5\u5f80\u5f80\u6ca1\u90a3\u4e48\u7b80\u5355&#xff1a;\u5efa\u7d22\u5f15\u662f\u95e8\u6280\u672f\u6d3b&#xff0c;\u4e0d\u5408\u9002\u7684\u7d22\u5f15\u4e0d\u4ec5\u4e0d\u4f1a\u63d0\u901f&#xff0c;\u53cd\u800c\u53ef\u80fd\u62d6\u6162\u6027\u80fd&#xff0c;\u751a\u81f3\u5f15\u53d1\u6162\u67e5\u8be2\u3002 \u5728\u6240\u6709\u7d22\u5f15\u7c7b\u578b\u4e2d&#xff0c;\u8054\u5408\u7d22\u5f15&#xff08;Composite Index&#xff09;\u56e0\u5176\u9ad8\u7075\u6d3b\u6027\u3001\u9002\u7528\u9762\u5e7f\u800c\u88ab\u5e7f\u6cdb\u5e94\u7528&#xff0c;\u51e0\u4e4e\u6210\u4e86\u6bcf\u4e2a\u4e1a\u52a1\u7cfb\u7edf\u5fc5\u5907\u7684\u6027\u80fd\u4f18\u5316\u624b\u6bb5\u3002\u4f46\u4f60\u662f\u5426\u771f\u6b63\u4e86\u89e3&#xff0c;\u8054\u5408\u7d22\u5f15\u5230\u5e95\u662f\u600e\u4e48\u5de5\u4f5c\u7684&#xff1f;\u5b83\u9002\u5408\u54ea\u4e9b\u573a\u666f&#xff1f;\u4ec0\u4e48\u65f6\u5019\u4f1a\u5931\u6548&#xff1f;\u53c8\u8be5\u5982\u4f55\u6b63\u786e\u4f7f\u7528&#xff1f; \u672c\u8282\u6211\u4eec\u5c31\u4ece MySQL \u7684\u7d22\u5f15\u5206\u7c7b\u5165\u624b&#xff0c;\u9010\u6b65\u5256\u6790\u8054\u5408\u7d22\u5f15\u7684\u7ed3\u6784\u3001\u539f\u7406\u548c\u4f18\u52bf&#xff0c;\u4e3a\u540e\u9762\u6df1\u5165\u8ba8\u8bba\u5176\u5728\u5b9e\u6218\u4e2d\u7684\u5e94\u7528\u6253\u597d\u57fa\u7840\u3002<\/p>\n<h3 id=\"%EF%BC%88%E4%B8%80%EF%BC%89%E7%B4%A2%E5%BC%95%E7%9A%84%E5%9F%BA%E6%9C%AC%E7%BB%93%E6%9E%84%EF%BC%9A%E4%BB%8E%E8%81%9A%E7%B0%87%E5%88%B0%E9%9D%9E%E8%81%9A%E7%B0%87\">&#xff08;\u4e00&#xff09;\u7d22\u5f15\u7684\u57fa\u672c\u7ed3\u6784&#xff1a;\u4ece\u805a\u7c07\u5230\u975e\u805a\u7c07<\/h3>\n<p>MySQL \u4e2d\u7684\u7d22\u5f15&#xff0c;\u5176\u80cc\u540e\u6838\u5fc3\u7684\u6570\u636e\u7ed3\u6784\u662f B&#043; \u6811&#xff0c;\u4f46\u6839\u636e\u6570\u636e\u4e0e\u7d22\u5f15\u7684\u7269\u7406\u5b58\u50a8\u65b9\u5f0f\u4e0d\u540c&#xff0c;\u53c8\u53ef\u4ee5\u5206\u4e3a\u4ee5\u4e0b\u4e24\u79cd\u7c7b\u578b&#xff1a;<\/p>\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"248\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250810101440-68987110eafe6.png\" width=\"500\" \/><\/p>\n<h4 id=\"1.%20%E8%81%9A%E7%B0%87%E7%B4%A2%E5%BC%95%EF%BC%88Clustered%20Index%EF%BC%89\">1. \u805a\u7c07\u7d22\u5f15&#xff08;Clustered Index&#xff09;<\/h4>\n<ul>\n<li>\n<p>\u6982\u5ff5&#xff1a; \u805a\u7c07\u7d22\u5f15\u662f\u6307\u6570\u636e\u884c\u7684\u7269\u7406\u987a\u5e8f\u548c\u7d22\u5f15\u987a\u5e8f\u4e00\u81f4&#xff0c;\u7d22\u5f15\u7684\u53f6\u5b50\u8282\u70b9\u4e0a\u5c31\u76f4\u63a5\u5b58\u50a8\u4e86\u6574\u884c\u7684\u6570\u636e\u3002\u8fd9\u610f\u5473\u7740&#xff0c;\u805a\u7c07\u7d22\u5f15\u65e2\u662f\u7d22\u5f15\u53c8\u662f\u6570\u636e\u672c\u8eab&#xff0c;\u5b83\u4eec\u662f\u5408\u5e76\u5728\u4e00\u8d77\u7684\u3002<\/p>\n<\/li>\n<li>\n<p>InnoDB\u4e2d\u7684\u7279\u6027&#xff1a; \u5728 InnoDB \u5f15\u64ce\u4e2d&#xff0c;\u6bcf\u5f20\u8868\u53ea\u80fd\u6709\u4e00\u4e2a\u805a\u7c07\u7d22\u5f15&#xff0c;\u901a\u5e38\u5c31\u662f\u4e3b\u952e\u7d22\u5f15\u3002\u5982\u679c\u4f60\u6ca1\u8bbe\u7f6e\u4e3b\u952e&#xff0c;InnoDB \u4f1a\u5e2e\u4f60\u9009\u62e9\u4e00\u4e2a\u552f\u4e00\u975e\u7a7a\u7684\u5b57\u6bb5\u4f5c\u4e3a\u4e3b\u952e&#xff1b;\u5982\u679c\u6ca1\u6709\u552f\u4e00\u5b57\u6bb5&#xff0c;\u5b83\u751a\u81f3\u4f1a\u9690\u5f0f\u521b\u5efa\u4e00\u4e2a\u5185\u90e8\u4e3b\u952e\u3002<\/p>\n<\/li>\n<li>\n<p>\u4f18\u70b9&#xff1a; \u67e5\u8be2\u4e3b\u952e\u975e\u5e38\u5feb&#xff0c;\u4e0d\u9700\u8981\u201c\u56de\u8868\u201d\u64cd\u4f5c\u3002<\/p>\n<\/li>\n<li>\n<p>\u7f3a\u70b9&#xff1a; \u53ea\u80fd\u6709\u4e00\u4e2a&#xff0c;\u4e14\u4e00\u65e6\u4e3b\u952e\u9891\u7e41\u66f4\u65b0\u6216\u63d2\u5165\u987a\u5e8f\u4e0d\u5408\u7406&#xff0c;\u4f1a\u5bfc\u81f4\u9875\u5206\u88c2\u3001\u78c1\u76d8\u788e\u7247&#xff0c;\u5f71\u54cd\u6027\u80fd\u3002<\/p>\n<\/li>\n<\/ul>\n<h4 id=\"2.%20%E9%9D%9E%E8%81%9A%E7%B0%87%E7%B4%A2%E5%BC%95%EF%BC%88Secondary%20Index%EF%BC%89\">2. \u975e\u805a\u7c07\u7d22\u5f15&#xff08;Secondary Index&#xff09;<\/h4>\n<ul>\n<li>\n<p>\u6982\u5ff5&#xff1a; \u975e\u805a\u7c07\u7d22\u5f15\u7684\u53f6\u5b50\u8282\u70b9\u5e76\u4e0d\u5305\u542b\u5b8c\u6574\u7684\u884c\u6570\u636e&#xff0c;\u800c\u662f\u5b58\u50a8\u4e86\u5bf9\u5e94\u4e3b\u952e\u7684\u503c\u3002\u8981\u83b7\u53d6\u5b8c\u6574\u6570\u636e&#xff0c;MySQL \u9700\u8981\u518d\u901a\u8fc7\u4e3b\u952e\u7d22\u5f15\u8fdb\u884c\u4e00\u6b21\u67e5\u627e&#xff0c;\u8fd9\u4e00\u6b65\u53eb\u505a\u201c\u56de\u8868\u201d\u3002<\/p>\n<\/li>\n<li>\n<p>\u4f18\u70b9&#xff1a; \u53ef\u4ee5\u4e3a\u8868\u4e2d\u591a\u4e2a\u5217\u5355\u72ec\u521b\u5efa\u591a\u4e2a\u975e\u805a\u7c07\u7d22\u5f15&#xff0c;\u67e5\u8be2\u7075\u6d3b\u3002<\/p>\n<\/li>\n<li>\n<p>\u7f3a\u70b9&#xff1a; \u5982\u679c\u67e5\u8be2\u5b57\u6bb5\u4e0d\u5728\u7d22\u5f15\u8986\u76d6\u8303\u56f4\u5185&#xff0c;\u90fd\u4f1a\u89e6\u53d1\u56de\u8868&#xff0c;\u5f71\u54cd\u67e5\u8be2\u6548\u7387\u3002<\/p>\n<\/li>\n<\/ul>\n<h3 id=\"%EF%BC%88%E4%BA%8C%EF%BC%89%E4%B8%8D%E5%90%8C%E7%B4%A2%E5%BC%95%E7%9A%84%E9%80%82%E7%94%A8%E5%9C%BA%E6%99%AF%E4%B8%80%E8%A7%88\">&#xff08;\u4e8c&#xff09;\u4e0d\u540c\u7d22\u5f15\u7684\u9002\u7528\u573a\u666f\u4e00\u89c8<\/h3>\n<table>\n<tr>\u7d22\u5f15\u7c7b\u578b\u6982\u5ff5\u7b80\u4ecb\u9002\u7528\u573a\u666f<\/tr>\n<tbody>\n<tr>\n<td>\u4e3b\u952e\u7d22\u5f15<\/td>\n<td>\u8868\u7684\u552f\u4e00\u6807\u8bc6&#xff0c;\u662f\u805a\u7c07\u7d22\u5f15<\/td>\n<td>\u7cbe\u786e\u67e5\u627e\u3001\u4e3b\u952e\u6392\u5e8f<\/td>\n<\/tr>\n<tr>\n<td>\u552f\u4e00\u7d22\u5f15<\/td>\n<td>\u4fdd\u8bc1\u67d0\u5217\u503c\u552f\u4e00&#xff0c;\u5141\u8bb8 NULL<\/td>\n<td>\u552f\u4e00\u7ea6\u675f\u3001\u90ae\u7bb1\u3001\u7528\u6237\u540d\u7b49<\/td>\n<\/tr>\n<tr>\n<td>\u666e\u901a\u7d22\u5f15<\/td>\n<td>\u6700\u57fa\u7840\u7d22\u5f15\u7ed3\u6784&#xff0c;\u901a\u5e38\u5355\u5217<\/td>\n<td>\u8303\u56f4\u67e5\u8be2\u3001\u6a21\u7cca\u5339\u914d<\/td>\n<\/tr>\n<tr>\n<td>\u5168\u6587\u7d22\u5f15<\/td>\n<td>\u9488\u5bf9\u6587\u672c\u5185\u5bb9\u7684\u5173\u952e\u8bcd\u68c0\u7d22<\/td>\n<td>\u6587\u672c\u641c\u7d22\u3001\u6587\u7ae0\u5339\u914d<\/td>\n<\/tr>\n<tr>\n<td>\u8054\u5408\u7d22\u5f15<\/td>\n<td>\u591a\u5217\u7ec4\u5408\u6210\u4e00\u4e2a\u7d22\u5f15\u7ed3\u6784<\/td>\n<td>\u591a\u6761\u4ef6\u67e5\u8be2\u3001\u8303\u56f4&#043;\u6392\u5e8f\u3001\u8986\u76d6\u67e5\u8be2<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3 id=\"%EF%BC%88%E4%B8%89%EF%BC%89%E8%81%94%E5%90%88%E7%B4%A2%E5%BC%95%E7%9A%84%E7%99%BB%E5%9C%BA%EF%BC%9A%E4%B8%BA%E4%BB%80%E4%B9%88%E5%AE%83%E6%98%AF%E6%85%A2%20SQL%20%E7%9A%84%E8%A7%A3%E8%8D%AF%EF%BC%9F\">&#xff08;\u4e09&#xff09;\u8054\u5408\u7d22\u5f15\u7684\u767b\u573a&#xff1a;\u4e3a\u4ec0\u4e48\u5b83\u662f\u6162 SQL \u7684\u89e3\u836f&#xff1f;<\/h3>\n<p>\u8054\u5408\u7d22\u5f15&#xff08;Composite Index&#xff09;\u662f\u628a\u591a\u4e2a\u5217\u7ec4\u5408\u5728\u4e00\u8d77&#xff0c;\u6309\u7167\u56fa\u5b9a\u987a\u5e8f\u5efa\u7acb\u4e00\u4e2a B&#043; \u6811\u7d22\u5f15\u7ed3\u6784\u3002<\/p>\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"487\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250810101441-689871118bc6c.png\" width=\"500\" \/><\/p>\n<p>\u8fd9\u79cd\u7d22\u5f15\u80fd\u6781\u5927\u63d0\u9ad8\u591a\u6761\u4ef6\u67e5\u8be2\u7684\u6548\u7387&#xff0c;\u662f\u73b0\u5728\u4e92\u8054\u7f51\u4e1a\u52a1\u4e2d\u4f7f\u7528\u9891\u7387\u6700\u9ad8\u7684\u7d22\u5f15\u7c7b\u578b\u4e4b\u4e00\u3002<\/p>\n<ul>\n<li>\n<p>\u9ad8\u9002\u914d\u6027&#xff1a; \u53ef\u4ee5\u8986\u76d6\u591a\u4e2a\u5217\u7684\u67e5\u8be2\u6761\u4ef6&#xff0c;\u51cf\u5c11\u56de\u8868\u6b21\u6570\u3002<\/p>\n<\/li>\n<li>\n<p>\u9ad8\u6027\u80fd&#xff1a; \u652f\u6301\u8986\u76d6\u7d22\u5f15&#xff0c;\u907f\u514d\u8bbf\u95ee\u4e3b\u952e\u7d22\u5f15&#xff0c;\u51cf\u5c11 I\/O\u3002<\/p>\n<\/li>\n<li>\n<p>\u4f4e\u5c40\u9650\u6027&#xff1a; \u5728\u7ec4\u5408\u987a\u5e8f\u8bbe\u8ba1\u5408\u7406\u7684\u524d\u63d0\u4e0b&#xff0c;\u9002\u914d\u5404\u79cd\u4e1a\u52a1\u903b\u8f91\u3002<\/p>\n<\/li>\n<\/ul>\n<p>\u4f46\u540c\u65f6&#xff0c;\u8054\u5408\u7d22\u5f15\u4e5f\u5f88\u5bb9\u6613\u201c\u88ab\u7528\u9519\u201d&#xff1a;<\/p>\n<p>\u5f88\u591a\u4e1a\u52a1\u8868\u90fd\u5efa\u4e86\u8054\u5408\u7d22\u5f15&#xff0c;\u4f46\u4e0d\u5c11\u60c5\u51b5\u4e0b\u67e5\u8be2\u5e76\u6ca1\u6709\u547d\u4e2d\u7d22\u5f15&#xff0c;\u751a\u81f3\u5bfc\u81f4\u6162\u67e5\u8be2\u3002\u8fd9\u5f80\u5f80\u662f\u56e0\u4e3a\u5f00\u53d1\u4eba\u5458\u4e0d\u4e86\u89e3 \u6700\u5de6\u524d\u7f00\u5339\u914d\u539f\u5219\u3001\u7d22\u5f15\u4e0b\u63a8\u7b56\u7565&#xff0c;\u6216\u8005\u672a\u8003\u8651\u5b57\u6bb5\u987a\u5e8f\u5bf9\u7d22\u5f15\u547d\u4e2d\u7684\u5f71\u54cd\u3002<\/p>\n<p>\u56e0\u6b64&#xff0c;\u4e0b\u4e00\u90e8\u5206\u6211\u4eec\u4f1a\u91cd\u70b9\u5c55\u5f00\u8bb2\u89e3&#xff1a;\u8054\u5408\u7d22\u5f15\u5728\u7ed3\u6784\u4e0a\u7684\u7279\u70b9\u3001\u5728\u5b9e\u9645\u4e1a\u52a1&#xff08;\u5982\u7f8e\u56e2\u5916\u5356\u5e7f\u544a\u7cfb\u7edf&#xff09;\u4e2d\u7684\u4f7f\u7528\u7b56\u7565&#xff0c;\u4ee5\u53ca\u5982\u4f55\u89c4\u907f\u5e38\u89c1\u7684\u4f7f\u7528\u8bef\u533a\u3002<\/p>\n<h2 id=\"%E4%BA%8C%E3%80%81%E8%81%94%E5%90%88%E7%B4%A2%E5%BC%95%E7%9A%84%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84%E6%8E%A2%E7%A9%B6\">\u4e8c\u3001\u8054\u5408\u7d22\u5f15\u7684\u6570\u636e\u7ed3\u6784\u63a2\u7a76<\/h2>\n<h3 id=\"%EF%BC%88%E4%B8%80%EF%BC%89%E8%81%94%E5%90%88%E7%B4%A2%E5%BC%95%E7%9A%84%E5%9F%BA%E6%9C%AC%E7%BB%93%E6%9E%84\">&#xff08;\u4e00&#xff09;\u8054\u5408\u7d22\u5f15\u7684\u57fa\u672c\u7ed3\u6784<\/h3>\n<h4 id=\"1.%20%E7%B4%A2%E5%BC%95%E5%AD%98%E5%82%A8%E7%BB%93%E6%9E%84\">1. \u7d22\u5f15\u5b58\u50a8\u7ed3\u6784<\/h4>\n<p>\u5728\u7406\u89e3\u8054\u5408\u7d22\u5f15\u5982\u4f55\u63d0\u9ad8\u67e5\u8be2\u6548\u7387\u4e4b\u524d&#xff0c;\u9996\u5148\u9700\u8981\u4e86\u89e3\u5b83\u80cc\u540e\u7684\u5b58\u50a8\u7ed3\u6784\u3002\u7d22\u5f15\u7684\u5e95\u5c42\u5b58\u50a8\u65b9\u5f0f\u76f4\u63a5\u5f71\u54cd\u7740\u67e5\u8be2\u7684\u6027\u80fd\u548c\u6548\u7387\u3002\u901a\u8fc7\u6df1\u5165\u5206\u6790InnoDB\u7684\u5b58\u50a8\u7ed3\u6784&#xff0c;\u6211\u4eec\u53ef\u4ee5\u66f4\u6e05\u695a\u5730\u7406\u89e3\u4e3a\u4ec0\u4e48\u8054\u5408\u7d22\u5f15\u80fd\u591f\u5728\u591a\u6761\u4ef6\u67e5\u8be2\u4e2d\u63d0\u4f9b\u4f18\u52bf\u3002<\/p>\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"318\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250810101442-6898711274cfe.png\" width=\"500\" \/><\/p>\n<p>InnoDB\u4e2d\u7684\u7d22\u5f15\u7ed3\u6784\u5206\u4e3a\u591a\u4e2a\u5c42\u6b21&#xff0c;\u5176\u4e2d\u5305\u542b\u6bb5&#xff08;segment&#xff09;\u3001\u7c07&#xff08;extends&#xff0c;\u6709\u4e9b\u6587\u732e\u4e5f\u79f0\u4e3a\u533a&#xff09;\u548c\u9875&#xff08;page&#xff09;\u3002<\/p>\n<h5 id=\"1.1%20%E5%B1%80%E9%83%A8%E9%A2%84%E8%AF%BB%E6%80%A7%E5%8E%9F%E7%90%86\">1.1 \u5c40\u90e8\u9884\u8bfb\u6027\u539f\u7406<\/h5>\n<p>\u6bcf\u4e00\u5c42\u6b21\u7684\u7ed3\u6784\u90fd\u4e0e\u78c1\u76d8I\/O\u64cd\u4f5c\u548c\u5c40\u90e8\u9884\u8bfb\u6027\u539f\u7406\u76f8\u5173\u3002<\/p>\n<ul>\n<li>\n<p>\u6bb5&#xff08;Segment&#xff09;&#xff1a;\u6bb5\u662f\u78c1\u76d8\u5b58\u50a8\u7684\u9876\u5c42\u7ed3\u6784&#xff0c;\u5305\u542b\u591a\u4e2a\u7c07\u3002\u6bcf\u4e2a\u6bb5\u7528\u4e8e\u5b58\u50a8\u4e00\u4e2a\u7279\u5b9a\u7c7b\u578b\u7684\u6570\u636e&#xff0c;\u5982\u6570\u636e\u8868\u7684\u5b9e\u9645\u6570\u636e\u6216\u7d22\u5f15\u6570\u636e\u3002<\/p>\n<\/li>\n<li>\n<p>\u7c07&#xff08;Extends\/\u533a&#xff09;&#xff1a;\u7c07\u662f\u5206\u914d\u7ed9\u4e00\u4e2a\u8868\u6216\u7d22\u5f15\u7684\u8fde\u7eed\u7684\u5b58\u50a8\u7a7a\u95f4\u5355\u4f4d&#xff0c;\u901a\u5e38\u753164\u4e2a\u9875\u9762\u7ec4\u6210\u3002\u7c07\u7684\u4f5c\u7528\u662f\u7ba1\u7406\u5b58\u50a8\u7684\u5206\u914d&#xff0c;\u6bcf\u4e2a\u7c07\u4f1a\u6839\u636e\u9700\u8981\u4ece\u6bb5\u4e2d\u5206\u914d\u9875\u9762\u3002\u5f53\u7c07\u6ee1\u65f6&#xff0c;\u7cfb\u7edf\u4f1a\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u7c07\u7ee7\u7eed\u5206\u914d\u7a7a\u95f4\u3002<\/p>\n<\/li>\n<li>\n<p>\u9875\u9762&#xff08;Page&#xff09;&#xff1a;\u9875\u9762\u662fInnoDB\u78c1\u76d8\u5b58\u50a8\u7684\u6700\u5c0f\u5355\u4f4d&#xff0c;\u6bcf\u4e2a\u9875\u9762\u5927\u5c0f\u901a\u5e38\u662f16KB\u3002\u9875\u9762\u4e2d\u5b58\u50a8\u7684\u6570\u636e\u53ef\u80fd\u662f\u8868\u4e2d\u7684\u5b9e\u9645\u6570\u636e&#xff0c;\u4e5f\u53ef\u80fd\u662f\u7d22\u5f15\u6570\u636e&#xff08;\u5982B&#043;\u6811\u8282\u70b9&#xff09;\u3002\u901a\u8fc7\u9875\u9762\u7684\u7ec4\u7ec7&#xff0c;\u6570\u636e\u5e93\u53ef\u4ee5\u6709\u6548\u5730\u7ba1\u7406\u548c\u68c0\u7d22\u6570\u636e\u3002<\/p>\n<\/li>\n<\/ul>\n<p>\u5c40\u90e8\u9884\u8bfb\u6027\u539f\u7406\u662f\u6307\u8ba1\u7b97\u673a\u5728\u8fdb\u884c\u6570\u636e\u8bfb\u53d6\u65f6&#xff0c;\u4f1a\u4e0d\u4ec5\u4ec5\u8bfb\u53d6\u8bf7\u6c42\u7684\u6570\u636e&#xff0c;\u8fd8\u4f1a\u8bfb\u53d6\u4e0e\u8bf7\u6c42\u6570\u636e\u76f8\u90bb\u7684\u6570\u636e\u3002\u8fd9\u662f\u64cd\u4f5c\u7cfb\u7edf\u4e3a\u4e86\u63d0\u9ad8\u6570\u636e\u8bfb\u53d6\u6548\u7387\u6240\u91c7\u53d6\u7684\u4e00\u79cd\u7b56\u7565\u3002\u7531\u4e8e\u64cd\u4f5c\u7cfb\u7edf\u901a\u8fc7 I\/O \u64cd\u4f5c\u8fdb\u884c\u78c1\u76d8\u6570\u636e\u7684\u52a0\u8f7d&#xff0c;\u56e0\u6b64\u7cfb\u7edf\u4f1a\u66f4\u503e\u5411\u4e8e\u8bfb\u53d6\u4e00\u4e2a\u8303\u56f4\u5185\u7684\u6570\u636e&#xff0c;\u800c\u4e0d\u662f\u968f\u673a\u8bfb\u53d6\u4e0d\u76f8\u5173\u7684\u6570\u636e\u3002<\/p>\n<h6 id=\"%E4%B8%BA%E4%BB%80%E4%B9%88%E8%BF%99%E6%A0%B7%E5%81%9A%EF%BC%9F\">\u4e3a\u4ec0\u4e48\u8fd9\u6837\u505a&#xff1f;<\/h6>\n<ul>\n<li>\n<p>\u5185\u5b58\u5230CPU\u7684\u5c40\u90e8\u9884\u8bfb\u6027&#xff1a;\u5f53CPU\u4ece\u5185\u5b58\u4e2d\u8bfb\u53d6\u6570\u636e\u65f6&#xff0c;\u6570\u636e\u901a\u5e38\u4f1a\u4ee5\u7f13\u5b58\u884c\u4e3a\u5355\u4f4d\u8fdb\u884c\u9884\u8bfb\u53d6\u3002\u8fd9\u662f\u56e0\u4e3a\u76f8\u90bb\u7684\u5185\u5b58\u5730\u5740\u6570\u636e\u5f88\u53ef\u80fd\u88ab\u540e\u7eed\u7684\u8ba1\u7b97\u8bbf\u95ee\u5230&#xff0c;\u8bfb\u53d6\u76f8\u90bb\u6570\u636e\u80fd\u51cf\u5c11CPU\u7684\u7b49\u5f85\u65f6\u95f4&#xff0c;\u63d0\u9ad8\u6548\u7387\u3002<\/p>\n<\/li>\n<li>\n<p>\u78c1\u76d8\u5230\u5185\u5b58\u7684\u5c40\u90e8\u9884\u8bfb\u6027&#xff1a;\u78c1\u76d8\u5728\u4e0e\u5185\u5b58\u8fdb\u884c\u6570\u636e\u4ea4\u6362\u65f6&#xff0c;\u4f1a\u6309\u7167\u5185\u5b58\u9875\u6765\u8bfb\u53d6\u6570\u636e\u3002\u78c1\u76d8\u4e2d\u7684\u6570\u636e\u88ab\u5206\u6210\u591a\u4e2a\u9875\u9762&#xff08;\u4f8b\u598216KB\u4e00\u4e2a\u9875\u9762&#xff09;&#xff0c;\u64cd\u4f5c\u7cfb\u7edf\u4f1a\u4e00\u6b21\u6027\u5c06\u4e00\u4e2a\u9875\u9762\u7684\u6570\u636e\u52a0\u8f7d\u5230\u5185\u5b58\u3002\u8fd9\u79cd\u52a0\u8f7d\u65b9\u5f0f\u5e76\u975e\u53ea\u662f\u52a0\u8f7d\u5355\u4e00\u7684\u6570\u636e\u9879&#xff0c;\u800c\u662f\u52a0\u8f7d\u6574\u5757\u6570\u636e&#xff0c;\u4ee5\u63d0\u9ad8\u8bfb\u53d6\u6570\u636e\u7684\u6548\u7387&#xff0c;\u56e0\u4e3a\u76f8\u90bb\u6570\u636e\u7684\u8bfb\u53d6\u5f80\u5f80\u662f\u9700\u8981\u7684\u3002<\/p>\n<\/li>\n<\/ul>\n<h4 id=\"2.%20%F0%9F%93%A6%20InnoDB%20%E7%9A%84%E9%A1%B5%EF%BC%88Page%EF%BC%89%EF%BC%9A%E5%AD%98%E5%82%A8%E7%9A%84%E6%9C%80%E5%B0%8F%E5%8D%95%E5%85%83\">2. &#x1f4e6; InnoDB \u7684\u9875&#xff08;Page&#xff09;&#xff1a;\u5b58\u50a8\u7684\u6700\u5c0f\u5355\u5143<\/h4>\n<p>\u5728 InnoDB \u5b58\u50a8\u5f15\u64ce\u4e2d&#xff0c;\u9875&#xff08;Page&#xff09;\u662f\u78c1\u76d8\u7ba1\u7406\u7684\u6700\u5c0f\u5355\u4f4d&#xff0c;\u4e5f\u662fB&#043;\u6811\u7d22\u5f15\u8282\u70b9\u7684\u5b9e\u9645\u7269\u7406\u8f7d\u4f53\u3002\u6bcf\u4e00\u4e2a\u9875\u7684\u5927\u5c0f\u56fa\u5b9a\u4e3a 16KB&#xff0c;\u7528\u4e8e\u5b58\u653e\u8868\u4e2d\u7684\u8bb0\u5f55\u3001\u7d22\u5f15\u7ed3\u6784&#xff0c;\u6216\u5176\u4ed6\u8f85\u52a9\u7cfb\u7edf\u4fe1\u606f\u3002<\/p>\n<p>\u9875\u9762\u7f16\u53f7&#xff08;Page Number&#xff09;\u5728\u903b\u8f91\u4e0a\u548c\u7269\u7406\u4e0a\u90fd\u662f\u8fde\u7eed\u9012\u589e\u7684&#xff0c;\u5373\u7f16\u53f7\u662f\u7ebf\u6027\u589e\u957f\u7684&#xff0c;\u8fd9\u6837\u8bbe\u8ba1\u53ef\u4ee5\u66f4\u597d\u5730\u5229\u7528\u5c40\u90e8\u9884\u8bfb\u6027&#xff08;\u4f8b\u5982\u8bfb\u53d6\u4e00\u4e2a\u9875\u9762\u65f6\u987a\u5e26\u8bfb\u53d6\u76f8\u90bb\u9875\u9762&#xff0c;\u4ece\u800c\u63d0\u5347\u6027\u80fd&#xff09;\u3002<\/p>\n<h5 id=\"2.1%20%E9%A1%B5%E9%9D%A2%E5%88%86%E9%85%8D%E8%BF%87%E7%A8%8B\">2.1 \u9875\u9762\u5206\u914d\u8fc7\u7a0b<\/h5>\n<p>\u5f53\u4f60\u5411\u8868\u4e2d\u63d2\u5165\u65b0\u6570\u636e\u65f6&#xff0c;InnoDB \u7684\u9875\u9762\u5206\u914d\u7b56\u7565\u5982\u4e0b&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u5982\u679c\u5f53\u524d\u9875\u9762\u5df2\u5199\u6ee1&#xff1a;\u7cfb\u7edf\u4f1a\u5728\u5f53\u524d\u7c07\u4e2d\u5bfb\u627e\u4e0b\u4e00\u4e2a\u7a7a\u95f2\u9875\u9762\u3002<\/p>\n<\/li>\n<li>\n<p>\u5982\u679c\u5f53\u524d\u7c07\u4e2d\u7684 64 \u4e2a\u9875\u9762\u90fd\u7528\u5b8c\u4e86&#xff1a;InnoDB \u4f1a\u4ece\u5f53\u524d\u6bb5\u4e2d\u5206\u914d\u4e00\u4e2a\u65b0\u7684\u7c07&#xff0c;\u7136\u540e\u4ece\u65b0\u7c07\u4e2d\u7ee7\u7eed\u5206\u914d\u9875\u9762\u3002<\/p>\n<\/li>\n<li>\n<p>\u6240\u6709\u8fd9\u4e9b\u7a7a\u95f4\u7684\u52a8\u6001\u6269\u5c55\u90fd\u7531InnoDB\u81ea\u52a8\u5b8c\u6210\u3002<\/p>\n<\/li>\n<\/ul>\n<p>\u8fd9\u79cd\u6309\u7c07\u6279\u91cf\u5206\u914d\u9875\u9762\u7684\u7b56\u7565&#xff0c;\u6b63\u662f\u4e3a\u4e86\u66f4\u597d\u5730\u652f\u6301\u5c40\u90e8\u9884\u8bfb\u6027&#xff0c;\u51cf\u5c11\u9891\u7e41\u7684\u78c1\u76d8I\/O\u3002<\/p>\n<h5 id=\"2.2%20%F0%9F%A7%AC%20%E9%A1%B5%E7%9A%84%E7%B1%BB%E5%9E%8B\">2.2 &#x1f9ec; \u9875\u7684\u7c7b\u578b<\/h5>\n<p>\u4e0d\u540c\u7528\u9014\u7684\u9875\u5728\u7ed3\u6784\u548c\u7528\u9014\u4e0a\u6709\u6240\u533a\u522b\u3002\u4e3b\u8981\u5305\u62ec&#xff1a;<\/p>\n<table>\n<tr>\u9875\u7c7b\u578b\u540d\u79f0\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td>BTreeNode<\/td>\n<td>\u6570\u636e\u9875<\/td>\n<td>\u7528\u4e8e\u5b58\u50a8\u7d22\u5f15\u7ed3\u6784\u548c\u8868\u6570\u636e&#xff08;\u4e3b\u952e\u6216\u8f85\u52a9\u7d22\u5f15\u7684B&#043;\u6811\u8282\u70b9&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>Undo Log Page<\/td>\n<td>Undo\u9875<\/td>\n<td>\u5b58\u50a8\u56de\u6eda\u65e5\u5fd7\u4fe1\u606f&#xff0c;\u652f\u6301\u4e8b\u52a1\u7684\u539f\u5b50\u6027<\/td>\n<\/tr>\n<tr>\n<td>System Page<\/td>\n<td>\u7cfb\u7edf\u9875<\/td>\n<td>\u5b58\u50a8\u5185\u90e8\u5143\u6570\u636e&#xff0c;\u4f8b\u5982\u7a7a\u95f4\u76ee\u5f55<\/td>\n<\/tr>\n<tr>\n<td>Transaction System Page<\/td>\n<td>\u4e8b\u52a1\u9875<\/td>\n<td>\u7ba1\u7406\u4e8b\u52a1\u72b6\u6001<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h5 id=\"2.3%20%F0%9F%A7%B1%20%E9%A1%B5%EF%BC%88Page%EF%BC%89%E7%9A%84%E5%86%85%E9%83%A8%E7%BB%93%E6%9E%84%EF%BC%9A%E4%B8%89%E6%AE%B5%E5%BC%8F%E5%B8%83%E5%B1%80\">2.3 &#x1f9f1; \u9875&#xff08;Page&#xff09;\u7684\u5185\u90e8\u7ed3\u6784&#xff1a;\u4e09\u6bb5\u5f0f\u5e03\u5c40<\/h5>\n<p>\u6bcf\u4e2a16KB\u5927\u5c0f\u7684\u9875\u5185\u90e8\u7ed3\u6784\u5982\u4e0b\u56fe\u6240\u793a&#xff1a;<\/p>\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"360\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250810101444-68987114aa50b.png\" width=\"400\" \/><\/p>\n<h5 id=\"%E2%9C%8F%EF%B8%8F%20%E5%85%B7%E4%BD%93%E8%AF%B4%E6%98%8E\">\u270f\ufe0f \u5177\u4f53\u8bf4\u660e<\/h5>\n<ul>\n<li>\n<p>\u9875\u5934&#xff08;38\u5b57\u8282&#xff09;<\/p>\n<ul>\n<li>\n<p>\u5b58\u50a8\u8be5\u9875\u7684\u5143\u6570\u636e&#xff0c;\u6bd4\u5982&#xff1a;\u9875\u7c7b\u578b\u3001\u9875\u7f16\u53f7\u3001\u524d\u540e\u9875\u6307\u9488&#xff08;\u53cc\u5411\u94fe\u8868\u7ed3\u6784&#xff09;\u7b49\u3002<\/p>\n<\/li>\n<li>\n<p>\u901a\u8fc7\u53cc\u5411\u94fe\u8868&#xff0c;\u6240\u6709\u9875\u5f62\u6210\u4e86\u4e00\u4e2a\u53ef\u904d\u5386\u7684\u94fe\u8868\u3002<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u6570\u636e\u533a\u57df&#xff08;\u4e2d\u95f4\u90e8\u5206&#xff09;<\/p>\n<ul>\n<li>\n<p>\u7528\u6765\u5b58\u50a8\u5b9e\u9645\u7684\u7528\u6237\u8bb0\u5f55\u6216\u7cfb\u7edf\u8bb0\u5f55&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u4e3b\u952e\u7d22\u5f15\u9875&#xff1a;\u53f6\u5b50\u8282\u70b9\u5b58\u653e key &#043; data&#xff08;\u6574\u884c\u8bb0\u5f55&#xff09;<\/p>\n<\/li>\n<li>\n<p>\u8f85\u52a9\u7d22\u5f15\u9875&#xff1a;\u53f6\u5b50\u8282\u70b9\u5b58\u653e key &#043; \u4e3b\u952e\u503c<\/p>\n<\/li>\n<li>\n<p>\u975e\u53f6\u5b50\u8282\u70b9&#xff1a;\u5b58\u653e key &#043; page \u6307\u9488<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u6570\u636e\u6309\u7167\u5355\u5411\u94fe\u8868\u7ed3\u6784\u5b58\u653e&#xff0c;\u5f62\u6210\u7d22\u5f15\u7684\u6709\u5e8f\u7ed3\u6784\u3002<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u9875\u5c3e&#xff08;8\u5b57\u8282&#xff09;<\/p>\n<ul>\n<li>\n<p>\u5b58\u653e\u8be5\u9875\u7684\u6821\u9a8c\u548c\u7b49\u4fe1\u606f&#xff0c;\u7528\u4e8e\u9632\u6b62\u6570\u636e\u635f\u574f\u3002<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>\u9875\u662fInnoDB\u78c1\u76d8\u7ba1\u7406\u7684\u57fa\u672c\u5355\u4f4d&#xff0c;\u6bcf\u987516KB\u3002\u901a\u8fc7\u6bb5 \u2192 \u7c07 \u2192 \u9875\u4e09\u7ea7\u5206\u914d\u7ed3\u6784&#xff0c;\u7ed3\u5408\u5c40\u90e8\u9884\u8bfb\u6027\u539f\u5219&#xff0c;InnoDB\u9ad8\u6548\u5730\u7ba1\u7406\u6570\u636e\u548c\u7d22\u5f15&#xff0c;\u4fdd\u8bc1\u4e86\u6570\u636e\u63d2\u5165\u548c\u67e5\u8be2\u7684\u6027\u80fd\u3002\u4e0d\u540c\u7c7b\u578b\u7684\u9875\u627f\u8f7d\u4e0d\u540c\u7684\u5185\u5bb9&#xff0c;\u6bd4\u5982\u6570\u636e\u9875\u3001Undo\u9875\u3001\u7cfb\u7edf\u9875\u7b49\u3002\u800c\u6bcf\u4e2a\u9875\u9762\u5185\u90e8\u7ed3\u6784\u4e5f\u9075\u5faa\u201c\u9875\u5934 &#043; \u6570\u636e\u533a\u57df &#043; \u9875\u5c3e\u201d\u7684\u56fa\u5b9a\u5e03\u5c40&#xff0c;\u4e3aB&#043;\u6811\u7d22\u5f15\u7ed3\u6784\u63d0\u4f9b\u4e86\u5f3a\u6709\u529b\u7684\u7269\u7406\u652f\u6301\u3002<\/p>\n<h4 id=\"3.%20%E8%81%9A%E7%B0%87%E7%B4%A2%E5%BC%95%20vs%20%E9%9D%9E%E8%81%9A%E7%B0%87%E7%B4%A2%E5%BC%95%E7%9A%84%E5%8F%B6%E5%AD%90%E8%8A%82%E7%82%B9%E8%AE%BF%E9%97%AE%E7%BB%93%E6%9E%84\">3. \u805a\u7c07\u7d22\u5f15 vs \u975e\u805a\u7c07\u7d22\u5f15\u7684\u53f6\u5b50\u8282\u70b9\u8bbf\u95ee\u7ed3\u6784<\/h4>\n<p>\u5728InnoDB\u4e2d&#xff0c;\u7d22\u5f15\u662f\u4ee5B&#043;\u6811\u7ed3\u6784\u7ec4\u7ec7\u7684&#xff0c;\u65e0\u8bba\u662f\u805a\u7c07\u7d22\u5f15&#xff08;Clustered Index&#xff09;\u8fd8\u662f\u975e\u805a\u7c07\u7d22\u5f15&#xff08;Secondary Index&#xff09;&#xff0c;\u5176\u5185\u90e8\u8282\u70b9\u7684\u7ba1\u7406\u90fd\u4f9d\u8d56\u4e8e\u9875\u9762&#xff08;Page&#xff09;\u8fd9\u4e00\u6700\u5c0f\u5355\u4f4d\u3002\u5c24\u5176\u5728\u53f6\u5b50\u8282\u70b9\u5c42\u9762&#xff0c;\u9875\u9762\u95f4\u7684\u8bbf\u95ee\u7ed3\u6784\u5b58\u5728\u660e\u663e\u5dee\u5f02&#xff0c;\u8fd9\u79cd\u5dee\u5f02\u5bf9\u67e5\u8be2\u8def\u5f84\u3001\u6570\u636e\u5b9a\u4f4d\u3001\u751a\u81f3I\/O\u6027\u80fd\u90fd\u6709\u6df1\u8fdc\u5f71\u54cd\u3002<\/p>\n<h5 id=\"3.1%20%F0%9F%94%B7%20%E8%81%9A%E7%B0%87%E7%B4%A2%E5%BC%95%EF%BC%88Clustered%20Index%EF%BC%89%E7%9A%84%E5%8F%B6%E5%AD%90%E8%8A%82%E7%82%B9%E8%AE%BF%E9%97%AE%E7%BB%93%E6%9E%84\">3.1 &#x1f537; \u805a\u7c07\u7d22\u5f15&#xff08;Clustered Index&#xff09;\u7684\u53f6\u5b50\u8282\u70b9\u8bbf\u95ee\u7ed3\u6784<\/h5>\n<p>\u805a\u7c07\u7d22\u5f15\u662fInnoDB\u7684\u9ed8\u8ba4\u7d22\u5f15\u7c7b\u578b&#xff0c;\u6bcf\u5f20\u8868\u90fd\u6709\u4e14\u4ec5\u6709\u4e00\u4e2a\u805a\u7c07\u7d22\u5f15\u3002\u5b83\u7684\u6700\u5927\u7279\u70b9\u5728\u4e8e&#xff1a;B&#043;\u6811\u7684\u53f6\u5b50\u8282\u70b9\u5c31\u662f\u6570\u636e\u672c\u8eab&#xff0c;\u5373\u6570\u636e\u8bb0\u5f55\u6309\u7167\u4e3b\u952e\u987a\u5e8f\u5b58\u50a8\u5728\u53f6\u5b50\u8282\u70b9\u4e0a\u3002<\/p>\n<h6 id=\"%E2%9C%85%20%E9%A1%B5%E9%9D%A2%E8%AE%BF%E9%97%AE%E7%BB%93%E6%9E%84%E7%89%B9%E7%82%B9\">\u2705 \u9875\u9762\u8bbf\u95ee\u7ed3\u6784\u7279\u70b9<\/h6>\n<ul>\n<li>\n<p>\u9875\u9762\u4e4b\u95f4\u901a\u8fc7\u53cc\u5411\u94fe\u8868\u8fde\u63a5&#xff0c;\u5373\u6bcf\u4e2a\u9875\u9762\u5728\u9875\u5934\u4e2d\u8bb0\u5f55\u524d\u5411\u6307\u9488&#xff08;Prev Page&#xff09;\u548c\u540e\u5411\u6307\u9488&#xff08;Next Page&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u9875\u9762\u5185\u90e8\u7684\u6570\u636e\u8bb0\u5f55\u6784\u6210\u5355\u5411\u94fe\u8868\u7ed3\u6784&#xff0c;\u901a\u8fc7\u8bb0\u5f55\u4e4b\u95f4\u7684next record\u5b57\u6bb5\u4e32\u8054\u3002<\/p>\n<\/li>\n<li>\n<p>\u6574\u4e2a\u53f6\u5b50\u5c42\u5929\u7136\u5f62\u6210\u4e86\u4e00\u4e2a\u6709\u5e8f\u7684\u6570\u636e\u5757\u533a\u95f4&#xff0c;\u4fbf\u4e8e\u8303\u56f4\u67e5\u8be2&#xff08;\u5982 BETWEEN\u3001&gt;\u3001&lt;&#xff09;\u3002<\/p>\n<\/li>\n<\/ul>\n<h6 id=\"%E2%9C%85%20%E4%BC%98%E5%8A%BF\">\u2705 \u4f18\u52bf<\/h6>\n<ul>\n<li>\n<p>\u67e5\u8be2\u4e3b\u952e\u6216\u4e3b\u952e\u8303\u56f4\u65f6&#xff0c;\u53ef\u4ee5\u901a\u8fc7\u53f6\u5b50\u9875\u7684\u987a\u5e8f\u904d\u5386\u5feb\u901f\u5b9a\u4f4d\u6570\u636e&#xff0c;\u65e0\u987b\u56de\u8868\u3002<\/p>\n<\/li>\n<li>\n<p>\u8303\u56f4\u626b\u63cf\u65f6&#xff0c;\u4ec5\u9700\u4e00\u6b21B&#043;\u6811\u5b9a\u4f4d&#xff0c;\u518d\u901a\u8fc7\u53f6\u5b50\u9875\u53cc\u5411\u94fe\u8868\u987a\u5e8f\u62c9\u53d6\u5373\u53ef&#xff0c;\u6781\u5927\u63d0\u5347\u78c1\u76d8\u9884\u8bfb\u6548\u7387\u3002<\/p>\n<\/li>\n<\/ul>\n<h6 id=\"%F0%9F%93%8C%20%E7%BB%93%E6%9E%84%E5%9B%BE%E7%A4%BA%E6%84%8F%EF%BC%9A\">&#x1f4cc; \u7ed3\u6784\u56fe\u793a\u610f&#xff1a;<\/h6>\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"221\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250810101446-689871167c363.png\" width=\"500\" \/><\/p>\n<h5 id=\"3.2%20%F0%9F%94%B7%20%E9%9D%9E%E8%81%9A%E7%B0%87%E7%B4%A2%E5%BC%95%EF%BC%88Secondary%20Index%EF%BC%89%E7%9A%84%E5%8F%B6%E5%AD%90%E8%8A%82%E7%82%B9%E8%AE%BF%E9%97%AE%E7%BB%93%E6%9E%84\">3.2 &#x1f537; \u975e\u805a\u7c07\u7d22\u5f15&#xff08;Secondary Index&#xff09;\u7684\u53f6\u5b50\u8282\u70b9\u8bbf\u95ee\u7ed3\u6784<\/h5>\n<p>\u975e\u805a\u7c07\u7d22\u5f15\u4e5f\u57fa\u4e8eB&#043;\u6811&#xff0c;\u4f46\u5176\u53f6\u5b50\u8282\u70b9\u4e2d\u4e0d\u5b58\u50a8\u5b8c\u6574\u7684\u6570\u636e\u884c\u8bb0\u5f55&#xff0c;\u800c\u662f\u5b58\u50a8&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u7d22\u5f15\u5217\u7684\u503c&#xff08;key&#xff09;<\/p>\n<\/li>\n<li>\n<p>\u5bf9\u5e94\u8bb0\u5f55\u7684\u4e3b\u952e\u503c&#xff08;rowid&#xff09;<\/p>\n<\/li>\n<\/ul>\n<p>\u8981\u901a\u8fc7\u975e\u805a\u7c07\u7d22\u5f15\u83b7\u53d6\u5b8c\u6574\u6570\u636e&#xff0c;\u5fc5\u987b\u901a\u8fc7\u4e3b\u952e\u56de\u8868\u67e5\u8be2\u3002<\/p>\n<h6 id=\"%E2%9C%85%20%E9%A1%B5%E9%9D%A2%E8%AE%BF%E9%97%AE%E7%BB%93%E6%9E%84%E7%89%B9%E7%82%B9\">\u2705 \u9875\u9762\u8bbf\u95ee\u7ed3\u6784\u7279\u70b9<\/h6>\n<ul>\n<li>\n<p>\u4e0e\u805a\u7c07\u7d22\u5f15\u4e00\u6837&#xff0c;\u9875\u9762\u4e4b\u95f4\u901a\u8fc7\u53cc\u5411\u94fe\u8868\u7ec4\u7ec7&#xff0c;\u7528\u4e8e\u652f\u6301\u8303\u56f4\u626b\u63cf\u3002<\/p>\n<\/li>\n<li>\n<p>\u9875\u5185\u90e8\u7684\u8bb0\u5f55\u4f9d\u65e7\u4ee5\u5355\u5411\u94fe\u8868\u7ed3\u6784\u4e32\u8054\u3002<\/p>\n<\/li>\n<li>\n<p>\u4f46\u53f6\u5b50\u8282\u70b9\u4e2d\u5b58\u653e\u7684\u662f\u7d22\u5f15\u9879&#xff0c;\u800c\u4e0d\u662f\u6574\u884c\u6570\u636e\u3002<\/p>\n<\/li>\n<\/ul>\n<h6 id=\"%E2%9C%85%20%E7%89%B9%E7%82%B9%E4%B8%8E%E5%BD%B1%E5%93%8D\">\u2705 \u7279\u70b9\u4e0e\u5f71\u54cd<\/h6>\n<ul>\n<li>\n<p>\u7531\u4e8e\u53f6\u5b50\u9875\u53ea\u4fdd\u5b58\u7d22\u5f15\u9879 &#043; \u4e3b\u952e\u503c&#xff0c;\u56e0\u6b64\u5728\u7d22\u5f15\u5217\u4e0d\u80fd\u5b8c\u5168\u6ee1\u8db3\u67e5\u8be2\u5b57\u6bb5\u9700\u6c42\u65f6&#xff0c;\u9700\u8981\u201c\u56de\u8868\u201d\u64cd\u4f5c\u3002<\/p>\n<\/li>\n<li>\n<p>\u8303\u56f4\u67e5\u8be2\u4f9d\u7136\u80fd\u901a\u8fc7\u94fe\u5f0f\u7ed3\u6784\u652f\u6301\u9884\u8bfb&#xff0c;\u4f46\u6bd4\u805a\u7c07\u7d22\u5f15\u591a\u4e86\u4e00\u8df3\u56de\u8868I\/O&#xff0c;\u6027\u80fd\u53ef\u80fd\u53d7\u9650\u3002<\/p>\n<\/li>\n<\/ul>\n<h6 id=\"%F0%9F%93%8C%20%E7%BB%93%E6%9E%84%E5%9B%BE%E7%A4%BA%E6%84%8F\">&#x1f4cc; \u7ed3\u6784\u56fe\u793a\u610f<\/h6>\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"221\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250810101446-68987116bd2fb.png\" width=\"500\" \/><\/p>\n<h5 id=\"3.3%20%F0%9F%94%8D%20%E8%81%9A%E7%B0%87%E7%B4%A2%E5%BC%95%20vs%20%E9%9D%9E%E8%81%9A%E7%B0%87%E7%B4%A2%E5%BC%95%20%E8%AE%BF%E9%97%AE%E7%BB%93%E6%9E%84%E5%AF%B9%E6%AF%94%E6%80%BB%E7%BB%93\">3.3 &#x1f50d; \u805a\u7c07\u7d22\u5f15 vs \u975e\u805a\u7c07\u7d22\u5f15 \u8bbf\u95ee\u7ed3\u6784\u5bf9\u6bd4\u603b\u7ed3<\/h5>\n<table>\n<tr>\u5bf9\u6bd4\u7ef4\u5ea6\u805a\u7c07\u7d22\u5f15\u53f6\u5b50\u8282\u70b9\u975e\u805a\u7c07\u7d22\u5f15\u53f6\u5b50\u8282\u70b9<\/tr>\n<tbody>\n<tr>\n<td>\u9875\u9762\u95f4\u7ed3\u6784<\/td>\n<td>\u53cc\u5411\u94fe\u8868<\/td>\n<td>\u53cc\u5411\u94fe\u8868<\/td>\n<\/tr>\n<tr>\n<td>\u9875\u9762\u5185\u7ed3\u6784<\/td>\n<td>\u5355\u5411\u94fe\u8868&#xff08;\u6570\u636e\u8bb0\u5f55&#xff09;<\/td>\n<td>\u5355\u5411\u94fe\u8868&#xff08;\u7d22\u5f15\u9879&#043;\u4e3b\u952e&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>\u5b58\u50a8\u5185\u5bb9<\/td>\n<td>\u4e3b\u952e&#043;\u6574\u884c\u8bb0\u5f55<\/td>\n<td>\u7d22\u5f15\u5217&#043;\u4e3b\u952e\u503c<\/td>\n<\/tr>\n<tr>\n<td>\u67e5\u8be2\u5b8c\u6574\u884c<\/td>\n<td>\u76f4\u63a5\u547d\u4e2d<\/td>\n<td>\u9700\u8981\u56de\u8868<\/td>\n<\/tr>\n<tr>\n<td>\u8303\u56f4\u67e5\u8be2\u6548\u7387<\/td>\n<td>\u9ad8<\/td>\n<td>\u6b21\u4e4b&#xff08;\u53d7\u9650\u4e8e\u56de\u8868&#xff09;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3 id=\"%EF%BC%88%E4%BA%8C%EF%BC%89B%2B%E6%A0%91%E7%BB%93%E6%9E%84\">&#xff08;\u4e8c&#xff09;B&#043;\u6811\u7ed3\u6784<\/h3>\n<p>\u5728 MySQL \u7684 InnoDB \u5b58\u50a8\u5f15\u64ce\u4e2d&#xff0c;\u7d22\u5f15\u7684\u5e95\u5c42\u5b9e\u73b0\u91c7\u7528\u7684\u662f B&#043;\u6811\u7ed3\u6784\u3002\u65e0\u8bba\u662f\u4e3b\u952e\u7d22\u5f15&#xff08;\u805a\u7c07\u7d22\u5f15&#xff09;\u8fd8\u662f\u4e8c\u7ea7\u7d22\u5f15&#xff08;\u975e\u805a\u7c07\u7d22\u5f15&#xff09;&#xff0c;\u90fd\u57fa\u4e8e B&#043;\u6811\u6765\u7ec4\u7ec7\u6570\u636e\u3002\u800c\u5728\u7406\u89e3\u8054\u5408\u7d22\u5f15\u4e4b\u524d&#xff0c;\u9996\u5148\u9700\u8981\u5398\u6e05 B&#043;\u6811\u7684\u57fa\u672c\u7ed3\u6784\u53ca\u5176\u5728\u805a\u7c07\u7d22\u5f15\u4e0e\u975e\u805a\u7c07\u7d22\u5f15\u4e2d\u7684\u5e94\u7528\u5dee\u5f02\u3002<\/p>\n<h4 id=\"1.%20B%2B%E6%A0%91%E7%AE%80%E4%BB%8B\">1. B&#043;\u6811\u7b80\u4ecb<\/h4>\n<p>B&#043;\u6811\u662f\u4e00\u79cd\u591a\u8def\u5e73\u8861\u67e5\u627e\u6811&#xff0c;\u5b83\u5177\u5907\u4ee5\u4e0b\u5173\u952e\u7279\u5f81&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u6240\u6709\u7684\u6570\u636e\u8bb0\u5f55\u90fd\u4fdd\u5b58\u5728\u53f6\u5b50\u8282\u70b9&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u975e\u53f6\u5b50\u8282\u70b9\u4e0d\u5b58\u50a8\u5b9e\u9645\u6570\u636e&#xff0c;\u53ea\u5b58\u50a8\u7d22\u5f15\u952e&#xff08;\u4e3b\u952e\u503c&#xff09;\u548c\u6307\u5411\u5b50\u8282\u70b9\u7684\u6307\u9488&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u53f6\u5b50\u8282\u70b9\u4e4b\u95f4\u901a\u8fc7\u53cc\u5411\u94fe\u8868\u8fde\u63a5&#xff0c;\u4fbf\u4e8e\u8303\u56f4\u67e5\u8be2&#xff1b;<\/p>\n<\/li>\n<li>\n<p>B&#043;\u6811\u5177\u6709\u826f\u597d\u7684\u78c1\u76d8\u8bfb\u5199\u5c40\u90e8\u6027\u548cIO\u6548\u7387&#xff0c;\u662f\u6570\u636e\u5e93\u7cfb\u7edf\u4e2d\u666e\u904d\u4f7f\u7528\u7684\u6570\u636e\u7ed3\u6784\u3002<\/p>\n<\/li>\n<\/ul>\n<p>\u8fd9\u90e8\u5206\u5728\u5386\u53f2\u535a\u5ba2\u4e2d\u5df2\u7ecf\u8bb2\u89e3\u591a\u6b21\u4e86&#xff0c;\u53ef\u4ee5\u7ffb\u4e00\u4e0b\u4e13\u680f&#xff0c;\u8fd9\u91cc\u4e0d\u5c55\u5f00\u8bf4\u4e86\u3002<\/p>\n<h4 id=\"2.%20%E8%81%9A%E7%B0%87%E7%B4%A2%E5%BC%95%E4%B8%AD%E7%9A%84%20B%2B%E6%A0%91\">2. \u805a\u7c07\u7d22\u5f15\u4e2d\u7684 B&#043;\u6811<\/h4>\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"324\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250810101447-689871171010e.png\" width=\"800\" \/><\/p>\n<p>\u5982\u56fe\u6240\u793a&#xff0c;\u805a\u7c07\u7d22\u5f15\u7684 B&#043;\u6811\u7ed3\u6784\u5177\u6709\u4ee5\u4e0b\u7279\u70b9&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u975e\u53f6\u5b50\u8282\u70b9&#xff08;\u5982\u56fe\u4e2d\u7684\u78c1\u76d8\u57571~3&#xff09;\u4ec5\u5b58\u50a8\u4e3b\u952e\u503c\u548c\u5b50\u8282\u70b9\u6307\u9488&#xff0c;\u7528\u4e8e\u5bfc\u822a&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u53f6\u5b50\u8282\u70b9&#xff08;\u5982\u78c1\u76d8\u57574~7&#xff09;\u5b58\u50a8\u7684\u662f\u6574\u884c\u6570\u636e&#xff0c;\u4e5f\u5373\u6570\u636e\u9875\u3002\u6bcf\u6761\u8bb0\u5f55\u4ee5\u4e3b\u952e\u4f5c\u4e3a\u987a\u5e8f\u6392\u5217\u7684\u952e&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u53f6\u5b50\u8282\u70b9\u4e4b\u95f4\u901a\u8fc7\u53cc\u5411\u94fe\u8868\u76f8\u8fde&#xff0c;\u5b9e\u73b0\u8303\u56f4\u626b\u63cf\u80fd\u529b&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u63d2\u5165\u6570\u636e\u65f6&#xff0c;\u6570\u636e\u4f1a\u6309\u7167\u4e3b\u952e\u987a\u5e8f\u63d2\u5165\u5230\u76f8\u5e94\u53f6\u5b50\u8282\u70b9\u4e2d&#xff0c;\u786e\u4fdd\u6811\u7ed3\u6784\u7684\u6709\u5e8f\u6027\u3002<\/p>\n<\/li>\n<\/ul>\n<p>\u805a\u7c07\u7d22\u5f15\u7684\u5173\u952e\u7279\u6027\u5728\u4e8e&#xff1a;\u6570\u636e\u884c\u5b58\u50a8\u4e8e\u53f6\u5b50\u8282\u70b9\u4e2d&#xff0c;B&#043;\u6811\u7684\u53f6\u5b50\u8282\u70b9\u672c\u8eab\u5c31\u662f\u6570\u636e\u9875\u3002\u56e0\u6b64&#xff0c;\u8868\u4e2d\u6570\u636e\u7684\u7269\u7406\u5b58\u50a8\u987a\u5e8f\u662f\u6309\u7167\u4e3b\u952e\u6392\u5e8f\u7684&#xff0c;\u8fd9\u5bf9\u4e8e\u4e3b\u952e\u8303\u56f4\u67e5\u8be2\u6027\u80fd\u6709\u6781\u5927\u63d0\u5347\u3002<\/p>\n<h5 id=\"2.1%20B%2B%E6%A0%91%E8%AE%BF%E9%97%AE%E8%BF%87%E7%A8%8B%E4%B8%8E%E5%86%85%E5%AD%98%E9%A1%B5%E5%8A%A0%E8%BD%BD%E6%9C%BA%E5%88%B6\">2.1 B&#043;\u6811\u8bbf\u95ee\u8fc7\u7a0b\u4e0e\u5185\u5b58\u9875\u52a0\u8f7d\u673a\u5236<\/h5>\n<p>\u6839\u636e\u78c1\u76d8\u9884\u8bfb\u6027\u539f\u7406&#xff0c;\u6570\u636e\u5e93\u5728\u8bbf\u95ee B&#043;\u6811\u7ed3\u6784\u65f6&#xff0c;\u5e95\u5c42\u4f1a\u4ee5\u78c1\u76d8\u5757&#xff08;Disk Block&#xff09;\u4e3a\u5355\u4f4d\u4ece\u78c1\u76d8\u8bfb\u53d6\u6570\u636e&#xff0c;\u7136\u540e\u5c06\u5176\u52a0\u8f7d\u5230\u5185\u5b58\u4e2d&#xff0c;\u7531\u4e8e\u78c1\u76d8\u8bbf\u95ee\u7684\u901f\u5ea6\u8fdc\u6162\u4e8e\u5185\u5b58&#xff0c;\u56e0\u6b64\u8fd9\u79cd\u57fa\u4e8e\u9875\u7684\u9884\u8bfb\u7b56\u7565\u5bf9\u4e8e\u63d0\u5347\u67e5\u8be2\u6027\u80fd\u81f3\u5173\u91cd\u8981\u3002<\/p>\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"427\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250810101447-68987117955cc.png\" width=\"500\" \/><\/p>\n<p>\u4e0a\u56fe\u5c55\u793a\u4e86 B&#043;\u6811\u4ece\u78c1\u76d8\u5230\u5185\u5b58\u52a0\u8f7d\u7684\u8fc7\u7a0b&#xff0c;\u4ee5\u53ca\u5bf9\u5e94\u7684\u8bbf\u95ee\u8def\u5f84&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u78c1\u76d8\u5757\u4e0e\u5185\u5b58\u9875\u7684\u6620\u5c04&#xff1a;InnoDB \u4e2d\u78c1\u76d8\u7684\u6570\u636e\u9875\u5927\u5c0f\u56fa\u5b9a\u4e3a 16KB&#xff0c;\u5185\u5b58\u4e2d\u4ee5\u76f8\u540c\u5927\u5c0f\u7684\u9875&#xff08;Page&#xff09;\u7ba1\u7406\u3002\u56fe\u4e2d\u6a59\u8272\u533a\u57df\u8868\u793a\u78c1\u76d8\u5c42&#xff0c;\u9ec4\u8272\u533a\u57df\u8868\u793a\u5185\u5b58\u5c42\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bbf\u95ee\u8def\u5f84&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u8bbf\u95ee\u6570\u636e\u884c\u65f6&#xff0c;\u9996\u5148\u4ece\u78c1\u76d8\u57571\u52a0\u8f7d\u6839\u8282\u70b9&#xff08;\u56fe\u4e2d\u7eff\u8272\u6846&#xff09;\u5230\u5185\u5b58&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u7136\u540e\u6839\u636e\u7d22\u5f15\u952e\u67e5\u627e&#xff0c;\u4f9d\u6b21\u5411\u4e0b\u8bfb\u53d6\u5b50\u8282\u70b9&#xff08;\u78c1\u76d8\u57572~4&#xff09;&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u6700\u7ec8\u5b9a\u4f4d\u5230\u53f6\u5b50\u8282\u70b9\u6240\u5728\u7684\u78c1\u76d8\u5757&#xff08;\u78c1\u76d8\u57575~7&#xff09;&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u53f6\u5b50\u8282\u70b9\u4e2d\u5b58\u50a8\u7684\u662f\u4e3b\u952e\u4fe1\u606f\u548c\u6574\u884c\u6570\u636e&#xff0c;\u5982\u56fe\u4e2d\u5f20\u4e09\u3001\u674e\u56db\u7684\u6570\u636e\u3002<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>\u6bcf\u4e00\u6b21\u8bbf\u95ee\u8def\u5f84\u4e0a\u7684\u78c1\u76d8\u5757&#xff0c;\u90fd\u4f1a\u89e6\u53d1\u4e00\u6b21 IO \u64cd\u4f5c&#xff0c;\u7cfb\u7edf\u4f1a\u5c1d\u8bd5\u5c06\u78c1\u76d8\u5757\u9884\u8bfb\u5e76\u9a7b\u7559\u5728\u5185\u5b58\u4e2d&#xff0c;\u907f\u514d\u91cd\u590d IO\u3002<\/p>\n<h5 id=\"2.2%20%E5%90%AF%E5%8A%A8%E5%8A%A0%E8%BD%BD%E4%B8%8E%E7%BC%93%E5%AD%98%E9%A9%BB%E7%95%99\">2.2 \u542f\u52a8\u52a0\u8f7d\u4e0e\u7f13\u5b58\u9a7b\u7559<\/h5>\n<ul>\n<li>\n<p>\u542f\u52a8\u52a0\u8f7d&#xff1a;\u5728\u6570\u636e\u5e93\u542f\u52a8\u9636\u6bb5&#xff0c;InnoDB \u4f1a\u5c1d\u8bd5\u5c06 B&#043;\u6811\u7684\u6839\u8282\u70b9\u7b49\u5173\u952e\u7d22\u5f15\u9875\u9884\u5148\u52a0\u8f7d\u81f3\u5185\u5b58&#xff0c;\u5e38\u9a7b\u4ee5\u63d0\u9ad8\u540e\u7eed\u8bbf\u95ee\u6548\u7387&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u9875\u7f13\u5b58\u673a\u5236&#xff08;Buffer Pool&#xff09;&#xff1a;\u8fd9\u4e9b\u88ab\u52a0\u8f7d\u5165\u5185\u5b58\u7684\u9875\u5c06\u9a7b\u7559\u5728 InnoDB \u7684 Buffer Pool \u4e2d&#xff0c;\u5e76\u53c2\u4e0e LRU \u7b56\u7565\u7ba1\u7406&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u9875\u9762\u7ed3\u6784\u4e00\u81f4\u6027&#xff1a;\u4e3a\u4e86\u4fbf\u4e8e\u5728\u5185\u5b58\u4e2d\u7edf\u4e00\u7ba1\u7406\u78c1\u76d8\u9875\u4e0e\u5185\u5b58\u9875&#xff0c;InnoDB \u5c06\u9875\u5927\u5c0f\u8bbe\u7f6e\u4e3a\u4e00\u81f4&#xff0c;\u5373\u78c1\u76d8\u9875\u4e0e\u5185\u5b58\u9875\u5bb9\u91cf\u4e25\u683c\u5339\u914d&#xff08;\u5747\u4e3a16KB&#xff09;&#xff0c;\u65b9\u4fbf\u76f4\u63a5\u6620\u5c04\u3002<\/p>\n<\/li>\n<\/ul>\n<h5 id=\"2.3%20%E5%8F%8C%E5%90%91%E9%93%BE%E8%A1%A8%E4%B8%8E%E8%8C%83%E5%9B%B4%E6%9F%A5%E8%AF%A2%E4%BC%98%E5%8C%96\">2.3 \u53cc\u5411\u94fe\u8868\u4e0e\u8303\u56f4\u67e5\u8be2\u4f18\u5316<\/h5>\n<p>\u5982\u56fe\u6240\u793a&#xff0c;\u53f6\u5b50\u8282\u70b9\u4e2d\u7684\u8bb0\u5f55\u901a\u8fc7\u53cc\u5411\u94fe\u8868\u8fde\u63a5\u8d77\u6765&#xff08;ID&#061;1 \u5f20\u5f66\u5cf0 \u2194 ID&#061;100 \u7a0b\u7426&#xff09;&#xff0c;\u8fd9\u4f7f\u5f97\u8303\u56f4\u67e5\u8be2&#xff08;\u5982 WHERE id BETWEEN 10 AND 100&#xff09;\u4e0d\u9700\u8981\u56de\u6eaf\u4e0a\u5c42\u7d22\u5f15&#xff0c;\u800c\u662f\u53ef\u4ee5\u5728\u53f6\u5b50\u8282\u70b9\u94fe\u8868\u4e2d\u7ebf\u6027\u904d\u5386&#xff0c;\u5927\u5e45\u63d0\u5347\u67e5\u8be2\u6548\u7387\u3002<\/p>\n<h4 id=\"3.%20%E9%9D%9E%E8%81%9A%E7%B0%87%E7%B4%A2%E5%BC%95%E4%B8%AD%E7%9A%84%20B%2B%E6%A0%91\">3. \u975e\u805a\u7c07\u7d22\u5f15\u4e2d\u7684 B&#043;\u6811<\/h4>\n<p>\u4e0e\u805a\u7c07\u7d22\u5f15\u4e0d\u540c&#xff0c;\u975e\u805a\u7c07\u7d22\u5f15\u7684\u53f6\u5b50\u8282\u70b9\u4e2d\u4e0d\u5b58\u50a8\u5b8c\u6574\u6570\u636e\u884c&#xff0c;\u800c\u662f\u5b58\u50a8\u4e3b\u952e\u503c\u4f5c\u4e3a\u201c\u6307\u9488\u201d&#xff0c;\u7528\u4e8e\u56de\u8868\u67e5\u8be2\u3002\u8fd9\u4e00\u7279\u6027\u4f7f\u5f97\u975e\u805a\u7c07\u7d22\u5f15\u76f8\u6bd4\u805a\u7c07\u7d22\u5f15\u66f4\u5c0f\u3001\u66f4\u6d45&#xff0c;\u4f46\u9700\u8981\u901a\u8fc7\u4e3b\u952e\u518d\u6b21\u5b9a\u4f4d\u6570\u636e&#xff08;\u56de\u8868&#xff09;\u624d\u80fd\u53d6\u5230\u5b8c\u6574\u8bb0\u5f55\u3002<\/p>\n<p>\u4e5f\u5c31\u76f4\u63a5\u5728\u4e0b\u56fe\u4e2d\u8fdb\u884c\u4e86\u6807\u6ce8&#xff0c;\u8bf7\u6ce8\u610f\u6570\u636e\u5185\u5bb9\u7684\u66ff\u6362&#xff08;\u7eff\u8272\u7684\u6570\u636e\u66f4\u53d8\u4e3a\u4e86\u7ea2\u8272&#xff09;&#xff1a;<\/p>\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"331\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250810101448-6898711815ee9.png\" width=\"800\" \/><\/p>\n<p>\u975e\u805a\u7c07\u7d22\u5f15\u5728\u78c1\u76d8\u52a0\u8f7d\u673a\u5236\u4e0a\u4e0e\u805a\u7c07\u7d22\u5f15\u57fa\u672c\u4e00\u81f4&#xff0c;\u4f9d\u7136\u91c7\u7528 B&#043; Tree \u7ed3\u6784\u3002\u5728 InnoDB \u4e2d&#xff0c;B&#043; Tree \u7684\u6839\u8282\u70b9\u5728\u6570\u636e\u5e93\u5b9e\u4f8b\u542f\u52a8\u65f6\u5c31\u4f1a\u88ab\u52a0\u8f7d\u8fdb\u7f13\u51b2\u6c60&#xff08;Buffer Pool&#xff09;\u5e76\u5e38\u9a7b\u5185\u5b58&#xff0c;\u4ee5\u52a0\u5feb\u7d22\u5f15\u5b9a\u4f4d\u6548\u7387\u3002\u5176\u4ed6\u975e\u53f6\u5b50\u8282\u70b9\u4e0e\u53f6\u5b50\u8282\u70b9\u5219\u91c7\u7528\u6309\u9700\u52a0\u8f7d\u7b56\u7565&#xff0c;\u5373\u53ea\u6709\u5728\u8bbf\u95ee\u65f6\u624d\u4ece\u78c1\u76d8\u8bfb\u53d6\u5bf9\u5e94\u7684\u6570\u636e\u9875\u52a0\u8f7d\u81f3\u5185\u5b58\u4e2d\u3002\u5177\u4f53\u5982\u4e0b&#xff1a;<\/p>\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"415\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250810101448-68987118ac1b8.png\" width=\"700\" \/><\/p>\n<p>\u4e0e\u805a\u7c07\u7d22\u5f15\u7684\u533a\u522b\u5728\u4e8e&#xff1a;\u975e\u805a\u7c07\u7d22\u5f15\u7684\u53f6\u5b50\u8282\u70b9\u4e2d\u4e0d\u5b58\u50a8\u5b8c\u6574\u7684\u884c\u6570\u636e&#xff0c;\u800c\u662f\u5b58\u50a8\u7d22\u5f15\u5217\u7684\u952e\u503c\u53ca\u5bf9\u5e94\u8bb0\u5f55\u7684\u4e3b\u952e\u503c&#xff08;\u5373 RowID&#xff09;\u3002\u56e0\u6b64&#xff0c;\u5728\u4f7f\u7528\u975e\u805a\u7c07\u7d22\u5f15\u8fdb\u884c\u67e5\u8be2\u65f6&#xff0c;\u82e5\u67e5\u8be2\u5217\u4e0d\u5305\u542b\u5728\u7d22\u5f15\u4e2d&#xff0c;\u5c31\u9700\u8981\u6839\u636e\u4e3b\u952e\u503c\u56de\u8868\u5230\u805a\u7c07\u7d22\u5f15\u4e2d\u8fdb\u4e00\u6b65\u67e5\u627e\u884c\u6570\u636e\u3002\u8fd9\u79cd\u56de\u8868\u884c\u4e3a\u4f7f\u5f97\u975e\u805a\u7c07\u7d22\u5f15\u7684\u53f6\u5b50\u8282\u70b9\u5728\u52a0\u8f7d\u65f6&#xff0c;\u5176\u4e3b\u8981\u4f5c\u7528\u662f\u63d0\u4f9b\u56de\u8868\u6240\u9700\u7684\u4e3b\u952e\u5b9a\u4f4d\u4fe1\u606f&#xff0c;\u800c\u4e0d\u662f\u6570\u636e\u672c\u8eab\u3002<\/p>\n<h3 id=\"%EF%BC%88%E4%B8%89%EF%BC%89%E8%81%94%E5%90%88%E7%B4%A2%E5%BC%95B%2B%E6%A0%91%E7%BB%93%E6%9E%84\">&#xff08;\u4e09&#xff09;\u8054\u5408\u7d22\u5f15B&#043;\u6811\u7ed3\u6784<\/h3>\n<p>\u4e0b\u56fe\u5c55\u793a\u7684\u662f\u4e00\u4e2a\u7531\u4e24\u4e2a\u5217\u7ec4\u6210\u7684\u8054\u5408\u7d22\u5f15\u7684 B&#043; \u6811\u7ed3\u6784\u3002\u5728\u8be5\u7ed3\u6784\u4e2d&#xff0c;\u975e\u53f6\u5b50\u8282\u70b9&#xff08;\u5185\u90e8\u8282\u70b9&#xff09;\u4e2d\u5b58\u50a8\u7684\u662f\u7d22\u5f15\u952e\u503c\u7ec4\u5408&#xff08;\u5373\u8054\u5408\u7d22\u5f15\u952e\u7684\u524d\u7f00&#xff09;\u4e0e\u6307\u5411\u5b50\u8282\u70b9\u7684\u9875\u53f7&#xff08;Page Number&#xff09;\u4f5c\u4e3a\u6307\u9488&#xff0c;\u7528\u4e8e\u5b9a\u4f4d\u4e0b\u4e00\u5c42\u7d22\u5f15\u9875\u3002\u7d22\u5f15\u952e\u503c\u6309\u7167\u8054\u5408\u7d22\u5f15\u5b9a\u4e49\u7684\u5217\u987a\u5e8f\u8fdb\u884c\u5b57\u5178\u5e8f\u6392\u5217\u3002<\/p>\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"326\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250810101449-6898711997563.png\" width=\"800\" \/><\/p>\n<p>\u53f6\u5b50\u8282\u70b9\u540c\u6837\u5b58\u50a8\u8054\u5408\u7d22\u5f15\u952e\u503c\u7ec4\u5408&#xff0c;\u4f46\u5176\u6307\u9488\u90e8\u5206\u4e0d\u518d\u6307\u5411\u4e0b\u4e00\u7ea7\u7d22\u5f15\u9875&#xff0c;\u800c\u662f\u6307\u5411\u5bf9\u5e94\u6570\u636e\u884c\u6240\u5728\u7684\u805a\u7c07\u7d22\u5f15\u4e2d\u7684\u4e3b\u952e&#xff08;RowID \u6216\u805a\u7c07\u7d22\u5f15\u9875\u5730\u5740&#xff09;\u3002\u56e0\u6b64&#xff0c;\u8054\u5408\u7d22\u5f15\u7684\u53f6\u5b50\u8282\u70b9\u4e0d\u76f4\u63a5\u5305\u542b\u5b8c\u6574\u7684\u884c\u6570\u636e&#xff0c;\u800c\u662f\u901a\u8fc7\u4e3b\u952e\u6307\u9488\u652f\u6301\u56de\u8868\u67e5\u8be2\u3002<\/p>\n<h4 id=\"1.%20%F0%9F%8C%90%20%E8%81%94%E5%90%88%E7%B4%A2%E5%BC%95%E7%9A%84%E5%BA%95%E5%B1%82%E7%BB%93%E6%9E%84%E4%B8%8E%E8%AE%BE%E8%AE%A1%E6%B3%A8%E6%84%8F%E4%BA%8B%E9%A1%B9\">1. &#x1f310; \u8054\u5408\u7d22\u5f15\u7684\u5e95\u5c42\u7ed3\u6784\u4e0e\u8bbe\u8ba1\u6ce8\u610f\u4e8b\u9879<\/h4>\n<p>\u5728 MySQL \u7684 InnoDB \u5b58\u50a8\u5f15\u64ce\u4e2d&#xff0c;\u8054\u5408\u7d22\u5f15\u7684\u5e95\u5c42\u7ed3\u6784\u4f9d\u7136\u91c7\u7528 B&#043; \u6811&#xff0c;\u5176\u672c\u8d28\u5c5e\u4e8e\u4e8c\u7ea7\u7d22\u5f15&#xff08;\u975e\u805a\u7c07\u7d22\u5f15&#xff09;\u3002\u56e0\u6b64&#xff0c;B&#043; \u6811\u4e2d\u53f6\u5b50\u8282\u70b9\u6240\u5b58\u50a8\u7684\u5185\u5bb9\u5e76\u4e0d\u662f\u5b8c\u6574\u7684\u884c\u6570\u636e&#xff0c;\u800c\u662f&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u7d22\u5f15\u952e\u503c&#xff08;\u8054\u5408\u591a\u4e2a\u5217\u7684\u7ec4\u5408&#xff09;&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u4ee5\u53ca\u6307\u5411\u4e3b\u952e\u7d22\u5f15\u8bb0\u5f55\u7684 RowID&#xff08;\u5373\u4e3b\u952e\u503c&#xff09;&#xff0c;\u7528\u4e8e\u6267\u884c\u56de\u8868\u64cd\u4f5c\u83b7\u53d6\u5b8c\u6574\u6570\u636e\u3002<\/p>\n<\/li>\n<\/ul>\n<h4 id=\"2.%20%F0%9F%94%8D%20%E8%81%94%E5%90%88%E7%B4%A2%E5%BC%95%E7%9A%84%E9%81%8D%E5%8E%86%E9%80%BB%E8%BE%91%EF%BC%9A%E6%9C%80%E5%B7%A6%E5%89%8D%E7%BC%80%E5%8E%9F%E5%88%99\">2. &#x1f50d; \u8054\u5408\u7d22\u5f15\u7684\u904d\u5386\u903b\u8f91&#xff1a;\u6700\u5de6\u524d\u7f00\u539f\u5219<\/h4>\n<p>\u8054\u5408\u7d22\u5f15\u4e2d\u6bcf\u6761\u7d22\u5f15\u8bb0\u5f55\u7684\u952e\u503c&#xff0c;\u662f\u6309\u7167\u521b\u5efa\u7d22\u5f15\u65f6\u6307\u5b9a\u7684\u5217\u987a\u5e8f\u4f9d\u6b21\u7ec4\u5408\u800c\u6210\u7684\u3002\u4f8b\u5982&#xff1a;<\/p>\n<p>KEY idx_name_age_sex (name, age, sex) <\/p>\n<p>B&#043; \u6811\u904d\u5386\u7684\u89c4\u5219\u662f&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u4f18\u5148\u6bd4\u8f83\u6700\u5de6\u5217&#xff08;\u5982 name&#xff09;&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u5982\u679c name \u76f8\u540c&#xff0c;\u518d\u7ee7\u7eed\u6bd4\u8f83 age&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u82e5\u524d\u4e24\u5217\u90fd\u76f8\u540c&#xff0c;\u6700\u540e\u6bd4\u8f83 sex&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u904d\u5386\u8fc7\u7a0b\u4ece\u6839\u8282\u70b9\u9010\u5c42\u5411\u4e0b&#xff0c;\u76f4\u5230\u53f6\u5b50\u8282\u70b9\u3002<\/p>\n<\/li>\n<\/ul>\n<p>\u8fd9\u4e5f\u662f\u4e3a\u4ec0\u4e48\u8054\u5408\u7d22\u5f15\u5fc5\u987b\u9075\u5b88 \u6700\u5de6\u524d\u7f00\u5339\u914d\u89c4\u5219 \u7684\u6839\u672c\u539f\u56e0\u3002<\/p>\n<h4 id=\"3.%20%F0%9F%93%A6%20%E7%A3%81%E7%9B%98%E9%A1%B5%E7%BB%93%E6%9E%84%E5%AF%B9%E7%B4%A2%E5%BC%95%E6%80%A7%E8%83%BD%E7%9A%84%E5%BD%B1%E5%93%8D\">3. &#x1f4e6; \u78c1\u76d8\u9875\u7ed3\u6784\u5bf9\u7d22\u5f15\u6027\u80fd\u7684\u5f71\u54cd<\/h4>\n<p>InnoDB \u5c06\u78c1\u76d8\u5212\u5206\u4e3a\u56fa\u5b9a\u5927\u5c0f\u7684\u6570\u636e\u9875&#xff08;Page&#xff09;&#xff0c;\u6bcf\u9875\u9ed8\u8ba4\u5927\u5c0f\u4e3a 16KB\u3002\u6bcf\u4e2a\u9875\u4e2d\u5b58\u50a8\u7684\u662f\u82e5\u5e72\u6761\u201c\u952e\u503c &#043; \u6307\u9488\u201d\u7ec4\u5408\u3002\u5047\u8bbe&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u6bcf\u6761\u7d22\u5f15\u952e\u503c\u53ca\u5176\u6307\u9488\u7ea6\u5360 10 \u5b57\u8282&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u90a3\u4e48\u6bcf\u9875\u5927\u7ea6\u53ef\u4ee5\u5bb9\u7eb3 16KB \/ 10 \u2248 1600 \u6761\u8bb0\u5f55&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u82e5 B&#043; \u6811\u9ad8\u5ea6\u4e3a 3&#xff08;\u5e38\u89c1\u573a\u666f&#xff09;&#xff0c;\u5219\u6700\u591a\u53ef\u7ba1\u7406 1600 \u00d7 1600 &#061; \u7ea6 250 \u4e07\u4e2a\u53f6\u5b50\u8282\u70b9&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u6bcf\u4e2a\u53f6\u5b50\u8282\u70b9\u53c8\u53ef\u5b58\u50a8\u591a\u4e2a\u884c\u6307\u9488&#xff0c;\u56e0\u6b64\u603b\u5171\u53ef\u652f\u6301\u7684\u6570\u636e\u91cf\u975e\u5e38\u5e9e\u5927\u3002<\/p>\n<\/li>\n<\/ul>\n<p>\u7136\u800c&#xff0c;\u5982\u679c\u4f60\u7684\u8054\u5408\u7d22\u5f15\u5b57\u6bb5\u4e2d\u5305\u542b\u4e86\u5982 TEXT\u3001VARCHAR(255) \u6216 JSON \u5b57\u6bb5\u8fd9\u7c7b\u957f\u5ea6\u5927\u3001\u53d8\u52a8\u9891\u7e41\u7684\u5217&#xff0c;\u6bcf\u4e2a\u7d22\u5f15\u9879\u7684\u5927\u5c0f\u53ef\u80fd\u8fdc\u8d85 10 \u5b57\u8282\u3002\u7ed3\u679c\u5c31\u662f&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u6bcf\u4e2a\u78c1\u76d8\u9875\u53ef\u5bb9\u7eb3\u7684\u7d22\u5f15\u9879\u6570\u91cf\u5927\u5e45\u51cf\u5c11&#xff1b;<\/p>\n<\/li>\n<li>\n<p>B&#043; \u6811\u4e3a\u4e86\u4fdd\u6301\u6570\u636e\u7ec4\u7ec7&#xff0c;\u4f1a\u88ab\u8feb\u589e\u52a0\u66f4\u591a\u7684\u8282\u70b9\u6216\u63d0\u9ad8\u6811\u9ad8&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u8fd9\u76f4\u63a5\u5bfc\u81f4&#xff1a;\u66f4\u591a\u78c1\u76d8\u9875\u3001\u66f4\u6df1\u7684\u6811\u3001\u66f4\u9ad8\u7684\u78c1\u76d8 I\/O \u6b21\u6570&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u4ece\u800c\u62d6\u6162\u4e86\u7d22\u5f15\u904d\u5386\u548c\u6570\u636e\u5b9a\u4f4d\u7684\u6548\u7387\u3002<\/p>\n<\/li>\n<\/ul>\n<h4 id=\"4.%20%F0%9F%A7%A0%20%E4%B8%9A%E5%8A%A1%E5%9C%BA%E6%99%AF%E5%90%AF%E7%A4%BA\">4. &#x1f9e0; \u4e1a\u52a1\u573a\u666f\u542f\u793a<\/h4>\n<p>\u5728\u5927\u578b\u4e92\u8054\u7f51\u4e1a\u52a1\u4e2d&#xff0c;\u7cfb\u7edf\u67e5\u8be2\u91cf\u5927\u3001\u5b9e\u65f6\u6027\u5f3a&#xff0c;\u5bf9\u7d22\u5f15\u8bbe\u8ba1\u63d0\u51fa\u4e86\u975e\u5e38\u9ad8\u7684\u8981\u6c42\u3002\u7efc\u5408\u4ee5\u4e0a\u7279\u6027&#xff0c;\u6211\u4eec\u53ef\u4ee5\u5f97\u51fa\u4e00\u4e9b\u975e\u5e38\u5b9e\u7528\u7684\u8bbe\u8ba1\u5efa\u8bae&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u4f18\u5148\u4f7f\u7528\u957f\u5ea6\u77ed\u3001\u533a\u5206\u5ea6\u9ad8\u7684\u5b57\u6bb5\u5efa\u8054\u5408\u7d22\u5f15&#xff0c;\u5982 user_id\u3001status\u3001timestamp \u7b49&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u907f\u514d\u5c06 TEXT\u3001BLOB \u6216\u8d85\u957f VARCHAR \u5b57\u6bb5\u653e\u5165\u8054\u5408\u7d22\u5f15&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u5982\u679c\u9700\u8981\u7d22\u5f15\u90e8\u5206\u957f\u5b57\u6bb5&#xff0c;\u5c3d\u91cf\u4f7f\u7528\u524d\u7f00\u7d22\u5f15&#xff08;\u5982 varchar(255) \u5efa\u7d22\u5f15\u65f6\u6307\u5b9a varchar(20)&#xff09;&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u63a7\u5236\u7d22\u5f15\u7684\u6570\u91cf\u4e0e\u5197\u4f59\u5ea6&#xff0c;\u907f\u514d\u56e0\u4e3a\u201c\u7d22\u5f15\u5931\u63a7\u201d\u5e26\u6765\u7ef4\u62a4\u6210\u672c\u548c\u5199\u5165\u6027\u80fd\u4e0b\u964d&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u8054\u5408\u7d22\u5f15\u7684\u987a\u5e8f\u8981\u5339\u914d\u5b9e\u9645\u67e5\u8be2\u573a\u666f&#xff0c;\u4ee5\u6700\u5927\u5316\u547d\u4e2d\u7387&#xff0c;\u51cf\u5c11\u56de\u8868\u6b21\u6570\u3002<\/p>\n<\/li>\n<\/ul>\n<p>\u8054\u5408\u7d22\u5f15\u5e76\u975e\u201c\u5217\u8d8a\u591a\u8d8a\u5f3a\u201d&#xff0c;\u5b83\u7684\u5e95\u5c42\u7ed3\u6784\u51b3\u5b9a\u4e86\u5176\u5728\u5b58\u50a8\u548c\u67e5\u627e\u8fc7\u7a0b\u4e2d\u7684\u6027\u80fd\u74f6\u9888\u3002\u4e00\u65e6\u7d22\u5f15\u5217\u8bbe\u8ba1\u4e0d\u5408\u7406&#xff0c;\u7d22\u5f15\u9875\u81a8\u80c0\u3001B&#043; \u6811\u9ad8\u5ea6\u589e\u52a0\u3001\u78c1\u76d8 I\/O \u6fc0\u589e\u7b49\u95ee\u9898\u90fd\u4f1a\u663e\u73b0&#xff0c;\u8fdb\u800c\u5f71\u54cd\u6570\u636e\u5e93\u6574\u4f53\u6027\u80fd\u3002\u5728\u5343\u4e07\u7ea7\u6570\u636e\u89c4\u6a21\u7684\u4e92\u8054\u7f51\u7cfb\u7edf\u4e2d&#xff0c;\u5408\u7406\u8bbe\u8ba1\u8054\u5408\u7d22\u5f15\u5b57\u6bb5&#xff0c;\u63a7\u5236\u5176\u5bbd\u5ea6\u3001\u987a\u5e8f\u4e0e\u4f7f\u7528\u9891\u7387&#xff0c;\u624d\u80fd\u771f\u6b63\u53d1\u6325\u51fa\u8054\u5408\u7d22\u5f15\u7684\u6027\u80fd\u4f18\u52bf\u3002<\/p>\n<h2 id=\"%E4%B8%89%E3%80%81%E8%81%94%E5%90%88%E7%B4%A2%E5%BC%95%E7%9A%84%E5%8E%9F%E7%90%86%E4%B8%8E%E4%BC%98%E5%8C%96%E6%9C%BA%E5%88%B6\">\u4e09\u3001\u8054\u5408\u7d22\u5f15\u7684\u539f\u7406\u4e0e\u4f18\u5316\u673a\u5236<\/h2>\n<p>\u73b0\u5728\u6211\u4eec\u5f00\u59cb\u7cfb\u7edf\u8bb2\u89e3\u8054\u5408\u7d22\u5f15\u76f8\u8f83\u4e8e\u5355\u5217\u7d22\u5f15\u7684\u4f18\u52bf&#xff0c;\u8986\u76d6\u8054\u5408\u7d22\u5f15\u5728\u6267\u884c\u8ba1\u5212\u4e2d\u51cf\u5c11\u7b56\u7565\u5e72\u6270\u3001\u4f18\u5316\u56de\u8868\u6548\u7387\u3001\u52a0\u5f3a\u7d22\u5f15\u4e0b\u63a8\u80fd\u529b\u7b49\u65b9\u9762\u7684\u4f5c\u7528&#xff0c;\u5e76\u7ed3\u5408 MySQL \u7684\u6267\u884c\u903b\u8f91&#xff0c;\u5206\u6790\u8054\u5408\u7d22\u5f15\u7684\u4f7f\u7528\u573a\u666f\u548c\u6027\u80fd\u63d0\u5347\u539f\u7406\u3002<\/p>\n<h3 id=\"%EF%BC%88%E4%B8%80%EF%BC%89%E9%98%B2%E6%AD%A2%E7%B4%A2%E5%BC%95%E7%AD%96%E7%95%A5%E5%B9%B2%E6%89%B0%EF%BC%9A%E8%81%94%E5%90%88%E7%B4%A2%E5%BC%95%E4%B8%BA%E4%BD%95%E6%9B%B4%E7%A8%B3%E5%AE%9A%E5%8F%AF%E9%9D%A0\">&#xff08;\u4e00&#xff09;\u9632\u6b62\u7d22\u5f15\u7b56\u7565\u5e72\u6270&#xff1a;\u8054\u5408\u7d22\u5f15\u4e3a\u4f55\u66f4\u7a33\u5b9a\u53ef\u9760<\/h3>\n<p>\u5728 MySQL \u4e2d&#xff0c;\u67e5\u8be2\u8bed\u53e5\u4e2d WHERE \u6761\u4ef6\u6d89\u53ca\u591a\u4e2a\u5b57\u6bb5\u65f6&#xff0c;\u5982\u679c\u8fd9\u4e9b\u5b57\u6bb5\u5206\u522b\u5efa\u7acb\u4e86\u5355\u5217\u7d22\u5f15&#xff0c;\u90a3\u4e48 MySQL \u5728\u6267\u884c\u8ba1\u5212\u751f\u6210\u9636\u6bb5&#xff0c;\u5e76\u4e0d\u4f1a\u201c\u5929\u771f\u201d\u5730\u904d\u5386\u6240\u6709\u7d22\u5f15\u3002\u76f8\u53cd&#xff0c;\u5b83\u4f1a\u8bc4\u4f30\u5404\u4e2a\u7d22\u5f15\u7684\u9009\u62e9\u6027&#xff08;\u5373\u7d22\u5f15\u5b57\u6bb5\u7684\u533a\u5206\u5ea6&#xff09;&#xff0c;\u4f18\u5148\u9009\u62e9\u8fc7\u6ee4\u6548\u679c\u6700\u597d\u7684\u90a3\u4e00\u4e2a\u4f5c\u4e3a\u57fa\u7840\u7d22\u5f15\u3002\u8fd9\u79cd\u4f18\u5316\u7b56\u7565\u867d\u7136\u80fd\u63d0\u5347\u67d0\u4e9b\u573a\u666f\u4e0b\u7684\u6548\u7387&#xff0c;\u4f46\u4e5f\u5e26\u6765\u4e86\u4e0d\u786e\u5b9a\u6027 \u2014\u2014 \u591a\u4e2a\u5355\u5217\u7d22\u5f15\u53ef\u80fd\u4f1a\u88ab\u201c\u62e9\u4e00\u6267\u884c\u201d\u800c\u975e\u8054\u5408\u4f7f\u7528&#xff0c;\u4ece\u800c\u5f71\u54cd\u67e5\u8be2\u7ed3\u679c\u6216\u6027\u80fd\u8868\u73b0\u3002<\/p>\n<p>\u800c\u8054\u5408\u7d22\u5f15\u7ed3\u6784\u5219\u80fd\u6709\u6548\u89c4\u907f\u8fd9\u4e00\u6267\u884c\u7b56\u7565\u5e72\u6270\u95ee\u9898\u3002\u7531\u4e8e\u5176\u591a\u4e2a\u5b57\u6bb5\u503c\u662f\u7ec4\u5408\u6210\u4e00\u4e2a\u7d22\u5f15\u952e\u503c\u5b58\u50a8\u5728\u540c\u4e00\u4e2a B&#043; Tree \u7684\u6570\u636e\u57df\u4e2d&#xff08;\u800c\u975e\u5206\u6563\u5728\u591a\u4e2a\u7d22\u5f15\u7ed3\u6784\u91cc&#xff09;&#xff0c;\u56e0\u6b64 MySQL \u5728\u6267\u884c\u8ba1\u5212\u8bc4\u4f30\u65f6\u4f1a\u5c06\u5176\u89c6\u4e3a\u4e00\u4e2a\u6574\u4f53\u7d22\u5f15\u5355\u4f4d\u8fdb\u884c\u4f18\u5316&#xff0c;\u4ece\u800c\u907f\u514d\u4e86\u88ab\u62c6\u89e3\u6216\u66ff\u6362\u7684\u98ce\u9669&#xff0c;\u6267\u884c\u66f4\u7a33\u5b9a&#xff0c;\u6027\u80fd\u4e5f\u66f4\u5177\u53ef\u9884\u6d4b\u6027\u3002<\/p>\n<h4 id=\"1.%20%E2%9C%85%20%E7%A4%BA%E4%BE%8B%E5%AF%B9%E6%AF%94%E5%88%86%E6%9E%90\">1. \u2705 \u793a\u4f8b\u5bf9\u6bd4\u5206\u6790<\/h4>\n<p>\u5047\u8bbe\u6211\u4eec\u6709\u5982\u4e0b SQL \u67e5\u8be2&#xff1a;<\/p>\n<p>SELECT id, name, age, sex FROM user_table<br \/>\nWHERE name LIKE &#039;\u5f20%&#039; AND age &#061; 18;<\/p>\n<p>\u6b64\u65f6&#xff0c;name \u548c age \u5b57\u6bb5\u90fd\u5efa\u7acb\u4e86\u5355\u5217\u975e\u805a\u7c07\u7d22\u5f15&#xff0c;\u4f46\u672a\u6784\u5efa\u8054\u5408\u7d22\u5f15\u3002<\/p>\n<h5 id=\"1.1%20%E6%83%85%E5%86%B5%E4%B8%80%EF%BC%9A%E4%BD%BF%E7%94%A8%E5%A4%9A%E4%B8%AA%E5%8D%95%E5%88%97%E7%B4%A2%E5%BC%95\">1.1 \u60c5\u51b5\u4e00&#xff1a;\u4f7f\u7528\u591a\u4e2a\u5355\u5217\u7d22\u5f15<\/h5>\n<p>\u5728\u8fd9\u4e2a\u573a\u666f\u4e0b&#xff0c;MySQL Optimizer \u4f1a\u6839\u636e name \u548c age \u5404\u81ea\u7684\u533a\u5206\u5ea6&#xff08;cardinality&#xff09;\u51b3\u5b9a\u9009\u62e9\u54ea\u4e00\u4e2a\u4f5c\u4e3a\u6267\u884c\u7684\u4e3b\u7d22\u5f15\u8def\u5f84\u3002<\/p>\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"360\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250810101450-6898711a33cf4.png\" width=\"500\" \/><\/p>\n<p>\u4f8b\u5982&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u5982\u679c age \u5b57\u6bb5\u4e3a\u5e38\u7528\u503c&#xff08;\u5982 18 \u5360\u6bd4\u975e\u5e38\u9ad8&#xff09;&#xff0c;\u800c name \u5b57\u6bb5\u5206\u5e03\u66f4\u7a00\u758f&#xff0c;\u4f18\u5316\u5668\u5f88\u53ef\u80fd\u4f1a\u9009\u62e9 name \u4f5c\u4e3a\u4e3b\u7d22\u5f15&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u4f46\u5982\u679c\u4e24\u4e2a\u5b57\u6bb5\u7684\u533a\u5206\u5ea6\u63a5\u8fd1&#xff08;\u5dee\u5f02\u5c0f\u4e8e 1~2 \u4e2a\u6570\u91cf\u7ea7&#xff09;&#xff0c;\u53ef\u80fd\u4f1a\u91c7\u7528 Index Merge \u7b56\u7565&#xff08;\u5373\u4e24\u4e2a\u7d22\u5f15\u90fd\u7528&#xff0c;\u7ed3\u679c\u96c6\u518d\u5408\u5e76&#xff09;&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u65e0\u8bba\u662f\u54ea\u79cd\u65b9\u5f0f&#xff0c;\u90fd\u9700\u8981\u4ece\u9009\u4e2d\u7684\u7d22\u5f15\u53f6\u5b50\u8282\u70b9\u4e2d\u83b7\u53d6\u4e3b\u952e ID&#xff0c;\u518d\u56de\u8868\u67e5\u627e\u5b8c\u6574\u8bb0\u5f55&#xff0c;\u6700\u540e\u518d\u6839\u636e\u53e6\u4e00\u4e2a\u5b57\u6bb5\u8fdb\u884c\u8fc7\u6ee4\u3002<\/p>\n<\/li>\n<\/ul>\n<p>\u8fd9\u610f\u5473\u7740&#xff0c;\u5373\u4f7f\u6211\u4eec\u660e\u786e\u5728 WHERE \u6761\u4ef6\u4e2d\u4f7f\u7528\u4e86\u591a\u4e2a\u7d22\u5f15\u5b57\u6bb5&#xff0c;MySQL \u4e5f\u4e0d\u4e00\u5b9a\u6309\u6211\u4eec\u9884\u671f\u7684\u201c\u540c\u65f6\u4f7f\u7528\u201d\u5b83\u4eec\u6765\u7f29\u5c0f\u6570\u636e\u8303\u56f4&#xff0c;\u800c\u662f\u91c7\u7528\u67d0\u4e00\u4e2a\u6216\u5408\u5e76\u7684\u65b9\u5f0f&#xff0c;\u7ed3\u679c\u53ef\u80fd\u504f\u79bb\u9884\u671f\u3002<\/p>\n<h5 id=\"1.2%20%E6%83%85%E5%86%B5%E4%BA%8C%EF%BC%9A%E4%BD%BF%E7%94%A8%E8%81%94%E5%90%88%E7%B4%A2%E5%BC%95%20(name%2C%20age)\">1.2 \u60c5\u51b5\u4e8c&#xff1a;\u4f7f\u7528\u8054\u5408\u7d22\u5f15 (name, age)<\/h5>\n<p>\u5982\u679c\u6211\u4eec\u5728 user_table \u4e0a\u5efa\u7acb\u4e86 (name, age) \u7684\u8054\u5408\u7d22\u5f15&#xff1a;<\/p>\n<p>CREATE INDEX idx_name_age ON user_table(name, age); <\/p>\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"534\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250810101451-6898711b33a64.png\" width=\"500\" \/><\/p>\n<p>\u6b64\u65f6&#xff0c;MySQL \u5728\u6267\u884c\u8be5 SQL \u67e5\u8be2\u65f6&#xff0c;\u4f1a\u76f4\u63a5\u4ece idx_name_age \u8054\u5408\u7d22\u5f15\u7684 B&#043; Tree \u4e2d\u8fdb\u884c\u67e5\u627e&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u9996\u5148\u5339\u914d\u7b2c\u4e00\u5217 name LIKE &#039;\u5f20%&#039;&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u7136\u540e\u5728\u6240\u6709\u5339\u914d\u5230\u7684 name \u524d\u7f00\u4e2d\u7ee7\u7eed\u7b5b\u9009 age &#061; 18&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u5982\u679c\u67e5\u8be2\u5b57\u6bb5\u90fd\u5728\u8054\u5408\u7d22\u5f15\u4e2d\u88ab\u8986\u76d6&#xff08;\u5982 id, name, age&#xff09;&#xff0c;\u751a\u81f3\u65e0\u9700\u56de\u8868\u5373\u53ef\u76f4\u63a5\u8fd4\u56de\u7ed3\u679c&#xff0c;\u6781\u5927\u63d0\u5347\u67e5\u8be2\u6548\u7387\u3002<\/p>\n<\/li>\n<\/ul>\n<p>\u66f4\u5173\u952e\u7684\u662f&#xff0c;\u8054\u5408\u7d22\u5f15\u4e0d\u4f1a\u88ab MySQL \u62c6\u89e3\u6210\u591a\u4e2a\u7d22\u5f15\u6267\u884c&#xff0c;\u800c\u662f\u88ab\u4f18\u5316\u5668\u89c6\u4e3a\u4e00\u4e2a\u6574\u4f53\u8def\u5f84\u6765\u8d70&#xff0c;\u907f\u514d\u4e86\u5355\u5217\u7d22\u5f15\u4e2d\u201c\u8c01\u66f4\u4f18\u5c31\u7528\u8c01\u201d\u7684\u51b3\u7b56\u8fc7\u7a0b\u3002\u8fd9\u6b63\u662f\u6240\u8c13\u7684&#xff1a;<\/p>\n<p>\u201c\u8054\u5408\u7d22\u5f15\u662f\u4e00\u68f5\u6811&#xff0c;\u800c\u975e\u591a\u68f5\u6811\u7684\u7ade\u9009\u201d\u3002<\/p>\n<h4 id=\"2.%20%E2%9C%85%20%E4%B8%93%E4%B8%9A%E6%80%BB%E7%BB%93%EF%BC%9A%E4%B8%BA%E4%BD%95%E8%81%94%E5%90%88%E7%B4%A2%E5%BC%95%E8%83%BD%E8%A7%84%E9%81%BF%E7%AD%96%E7%95%A5%E5%B9%B2%E6%89%B0%EF%BC%9F\">2. \u2705 \u4e13\u4e1a\u603b\u7ed3&#xff1a;\u4e3a\u4f55\u8054\u5408\u7d22\u5f15\u80fd\u89c4\u907f\u7b56\u7565\u5e72\u6270&#xff1f;<\/h4>\n<table style=\"width:712px\">\n<tr>\u7279\u6027\u591a\u4e2a\u5355\u5217\u7d22\u5f15\u8054\u5408\u7d22\u5f15<\/tr>\n<tbody>\n<tr>\n<td style=\"width:203px\">\u662f\u5426\u4f5c\u4e3a\u4e00\u68f5 B&#043; \u6811\u7ed3\u6784<\/td>\n<td style=\"width:245px\">\u5404\u81ea\u72ec\u7acb\u6784\u5efa B&#043; Tree<\/td>\n<td style=\"width:261px\">\u6240\u6709\u5b57\u6bb5\u6784\u5efa\u5728\u4e00\u68f5 B&#043; Tree \u4e2d<\/td>\n<\/tr>\n<tr>\n<td style=\"width:203px\">\u662f\u5426\u53ef\u80fd\u88ab\u6267\u884c\u8ba1\u5212\u62c6\u89e3<\/td>\n<td style=\"width:245px\">\u2705 \u53ef\u80fd\u62e9\u4f18\u9009\u62e9\u4e00\u9879<\/td>\n<td style=\"width:261px\">\u274c \u59cb\u7ec8\u6574\u4f53\u53c2\u4e0e\u6267\u884c<\/td>\n<\/tr>\n<tr>\n<td style=\"width:203px\">\u662f\u5426\u80fd\u7a33\u5b9a\u547d\u4e2d\u6240\u6709\u6761\u4ef6\u5b57\u6bb5<\/td>\n<td style=\"width:245px\">\u274c \u4f9d\u8d56\u533a\u5206\u5ea6\u53ca\u6267\u884c\u8ba1\u5212\u9009\u62e9<\/td>\n<td style=\"width:261px\">\u2705 \u987a\u5e8f\u5339\u914d\u5b57\u6bb5\u7a33\u5b9a\u547d\u4e2d<\/td>\n<\/tr>\n<tr>\n<td style=\"width:203px\">\u662f\u5426\u5177\u5907\u7d22\u5f15\u8986\u76d6\u4f18\u52bf<\/td>\n<td style=\"width:245px\">\u274c \u9700\u8981\u591a\u6b21\u56de\u8868<\/td>\n<td style=\"width:261px\">\u2705 \u53ef\u4e00\u952e\u8986\u76d6\u67e5\u8be2\u5b57\u6bb5<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h6 id=\"%E2%9C%85%20%E5%B0%8F%E8%B4%B4%E5%A3%AB%EF%BC%9A%E4%BB%80%E4%B9%88%E6%98%AF%E7%B4%A2%E5%BC%95%E9%80%89%E6%8B%A9%E6%80%A7%EF%BC%9F\">\u2705 \u5c0f\u8d34\u58eb&#xff1a;\u4ec0\u4e48\u662f\u7d22\u5f15\u9009\u62e9\u6027&#xff1f;<\/h6>\n<p>\u7d22\u5f15\u9009\u62e9\u6027 &#061; \u552f\u4e00\u503c\u6570\u91cf \/ \u603b\u8bb0\u5f55\u6570 \u6570\u503c\u8d8a\u63a5\u8fd1 1&#xff0c;\u8fc7\u6ee4\u80fd\u529b\u8d8a\u5f3a&#xff0c;MySQL \u8d8a\u503e\u5411\u9009\u62e9\u5b83\u4f5c\u4e3a\u4e3b\u7d22\u5f15\u8def\u5f84\u3002<\/p>\n<p>\u4f8b\u5982&#xff0c;name \u6709 100 \u4e07\u4e2a\u552f\u4e00\u503c&#xff0c;age \u53ea\u6709 5 \u4e2a\u503c&#xff0c;\u90a3\u4e48 name \u7684\u9009\u62e9\u6027\u8fdc\u9ad8\u4e8e age&#xff0c;\u4f18\u5316\u5668\u66f4\u503e\u5411\u4e8e\u4f7f\u7528 name \u7684\u7d22\u5f15\u6765\u8fc7\u6ee4\u3002<\/p>\n<h4 id=\"3.%20%E2%9C%85%20%E5%AE%9E%E8%B7%B5%E5%BB%BA%E8%AE%AE\">3. \u2705 \u5b9e\u8df5\u5efa\u8bae<\/h4>\n<ul>\n<li>\n<p>\u591a\u5b57\u6bb5\u67e5\u8be2\u4e2d&#xff0c;\u4f18\u5148\u8003\u8651\u4f7f\u7528 \u8054\u5408\u7d22\u5f15&#xff0c;\u800c\u975e\u4f9d\u8d56\u591a\u4e2a\u5355\u5217\u7d22\u5f15&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u8054\u5408\u7d22\u5f15\u5b57\u6bb5\u987a\u5e8f\u9700\u7b26\u5408\u6700\u5de6\u524d\u7f00\u5339\u914d\u539f\u5219&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u53ef\u7ed3\u5408 EXPLAIN \u89c2\u5bdf\u5b9e\u9645\u7d22\u5f15\u4f7f\u7528\u60c5\u51b5&#xff0c;\u9a8c\u8bc1\u662f\u5426\u547d\u4e2d\u8054\u5408\u7d22\u5f15&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u5bf9\u4e8e\u9ad8\u5e76\u53d1\u8bfb\u5199\u573a\u666f\u4e0b\u7684\u7cbe\u786e\u5339\u914d\u8054\u5408\u7d22\u5f15&#xff0c;\u53ef\u6781\u5927\u51cf\u5c11\u78c1\u76d8 I\/O \u548c\u56de\u8868\u6b21\u6570&#xff0c;\u63d0\u5347\u6574\u4f53\u541e\u5410\u3002<\/p>\n<\/li>\n<\/ul>\n<h3 id=\"%EF%BC%88%E4%BA%8C%EF%BC%89%E7%B4%A2%E5%BC%95%E8%A6%86%E7%9B%96%E4%B8%8E%E6%9F%A5%E8%AF%A2%E4%BC%98%E5%8C%96%EF%BC%9A%E6%8F%90%E9%AB%98%E6%9F%A5%E8%AF%A2%E6%95%88%E7%8E%87\">&#xff08;\u4e8c&#xff09;\u7d22\u5f15\u8986\u76d6\u4e0e\u67e5\u8be2\u4f18\u5316&#xff1a;\u63d0\u9ad8\u67e5\u8be2\u6548\u7387<\/h3>\n<p>\u7d22\u5f15\u8986\u76d6&#xff08;Index Covering&#xff09;\u662f\u6307\u67e5\u8be2\u64cd\u4f5c\u4e2d\u7684\u6240\u6709\u5217\u90fd\u80fd\u88ab\u4e00\u4e2a\u7d22\u5f15\u8986\u76d6\u5e76\u8fd4\u56de\u7ed3\u679c&#xff0c;\u4ece\u800c\u907f\u514d\u4e86 \u56de\u8868&#xff08;table lookup&#xff09;\u64cd\u4f5c\u3002\u5728\u4f20\u7edf\u7684\u67e5\u8be2\u4e2d&#xff0c;\u5982\u679c\u6240\u9700\u7684\u6570\u636e\u5217\u4e0d\u5728\u7d22\u5f15\u4e2d&#xff0c;MySQL \u5fc5\u987b\u5148\u901a\u8fc7\u7d22\u5f15\u5b9a\u4f4d\u5230\u6570\u636e\u884c&#xff0c;\u7136\u540e\u6839\u636e\u4e3b\u952e\u6216\u884c\u6307\u9488\u67e5\u627e\u5bf9\u5e94\u7684\u8868\u8bb0\u5f55&#xff0c;\u8fdb\u884c\u56de\u8868\u64cd\u4f5c&#xff0c;\u8fd9\u4e2a\u8fc7\u7a0b\u4f1a\u589e\u52a0\u78c1\u76d8 I\/O \u5f00\u9500&#xff0c;\u964d\u4f4e\u67e5\u8be2\u6027\u80fd\u3002<\/p>\n<p>\u800c\u5728\u7d22\u5f15\u8986\u76d6\u7684\u60c5\u51b5\u4e0b&#xff0c;\u6240\u6709\u67e5\u8be2\u9700\u8981\u7684\u5b57\u6bb5\u90fd\u5df2\u5b58\u5728\u4e8e\u7d22\u5f15\u7684\u53f6\u5b50\u8282\u70b9\u4e2d&#xff0c;\u65e0\u9700\u56de\u8868\u5373\u53ef\u76f4\u63a5\u4ece\u7d22\u5f15\u4e2d\u83b7\u53d6\u6240\u9700\u6570\u636e\u3002\u901a\u8fc7\u5229\u7528 \u8054\u5408\u7d22\u5f15&#xff0c;\u53ef\u4ee5\u5c06\u591a\u4e2a\u5b57\u6bb5\u4e00\u8d77\u5b58\u50a8\u5728\u4e00\u4e2a\u7d22\u5f15\u7ed3\u6784\u4e2d&#xff0c;\u4f7f\u5f97\u67e5\u8be2\u65f6\u80fd\u591f\u4e00\u6b21\u6027\u83b7\u53d6\u6240\u6709\u76f8\u5173\u6570\u636e&#xff0c;\u51cf\u5c11\u4e86\u4e0d\u5fc5\u8981\u7684\u78c1\u76d8 I\/O\u3002<\/p>\n<h4 id=\"1.%20%E8%81%94%E5%90%88%E7%B4%A2%E5%BC%95%E7%9A%84%E8%A6%86%E7%9B%96%E8%83%BD%E5%8A%9B%EF%BC%9A%E9%81%BF%E5%85%8D%E5%9B%9E%E8%A1%A8\">1. \u8054\u5408\u7d22\u5f15\u7684\u8986\u76d6\u80fd\u529b&#xff1a;\u907f\u514d\u56de\u8868<\/h4>\n<p>\u8054\u5408\u7d22\u5f15\u80fd\u591f\u63d0\u4f9b\u5f3a\u5927\u7684\u7d22\u5f15\u8986\u76d6\u80fd\u529b&#xff0c;\u7279\u522b\u662f\u5728\u67e5\u8be2\u6761\u4ef6\u6d89\u53ca\u591a\u4e2a\u5b57\u6bb5\u65f6\u3002\u5047\u8bbe\u4f60\u5728\u8868\u4e2d\u521b\u5efa\u4e86\u4e00\u4e2a\u8054\u5408\u7d22\u5f15 (name, age)&#xff0c;\u5e76\u4e14\u67e5\u8be2\u4e2d\u6d89\u53ca\u5230\u8fd9\u4e24\u4e2a\u5b57\u6bb5&#xff0c;\u4f8b\u5982&#xff1a;<\/p>\n<p>SELECT name, age FROM table WHERE name LIKE &#039;\u5f20%&#039; AND age &#061; 18; <\/p>\n<p>\u5982\u679c\u8868\u4e2d\u5b58\u5728 (name, age) \u7684\u8054\u5408\u7d22\u5f15&#xff0c;MySQL \u5c31\u53ef\u4ee5\u76f4\u63a5\u4ece\u8be5\u8054\u5408\u7d22\u5f15\u7684\u53f6\u5b50\u8282\u70b9\u4e2d\u63d0\u53d6 name \u548c age \u7684\u503c&#xff0c;\u65e0\u9700\u56de\u8868\u5230\u4e3b\u952e\u7d22\u5f15\u53bb\u83b7\u53d6\u6570\u636e\u884c\u3002\u8fd9\u6837&#xff0c;\u67e5\u8be2\u7ed3\u679c\u5c31\u80fd\u901a\u8fc7\u8054\u5408\u7d22\u5f15\u4e00\u6b21\u6027\u83b7\u53d6&#xff0c;\u800c\u4e0d\u9700\u8981\u50cf\u975e\u8054\u5408\u7d22\u5f15\u90a3\u6837&#xff0c;\u901a\u8fc7\u4e3b\u952e\u6307\u9488\u56de\u8868\u67e5\u8be2\u3002<\/p>\n<p>\u8fd9\u79cd\u65b9\u5f0f\u7684\u597d\u5904\u5728\u4e8e&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u51cf\u5c11\u56de\u8868\u64cd\u4f5c&#xff1a;\u67e5\u8be2\u6240\u9700\u7684\u6240\u6709\u5b57\u6bb5\u90fd\u5305\u542b\u5728\u8054\u5408\u7d22\u5f15\u4e2d&#xff0c;\u907f\u514d\u4e86\u591a\u6b21\u67e5\u8be2\u548c\u78c1\u76d8 I\/O\u3002<\/p>\n<\/li>\n<li>\n<p>\u63d0\u5347\u67e5\u8be2\u6027\u80fd&#xff1a;\u901a\u8fc7\u51cf\u5c11\u56de\u8868\u6b21\u6570&#xff0c;\u80fd\u591f\u663e\u8457\u63d0\u5347\u67e5\u8be2\u7684\u54cd\u5e94\u901f\u5ea6&#xff0c;\u7279\u522b\u662f\u5728\u6570\u636e\u91cf\u5927\u3001\u67e5\u8be2\u9891\u7e41\u7684\u60c5\u51b5\u4e0b\u3002<\/p>\n<\/li>\n<\/ul>\n<h4 id=\"2.%20%E5%AE%9E%E8%B7%B5%E4%B8%AD%E7%9A%84%E5%BA%94%E7%94%A8%EF%BC%9A%E5%A6%82%E4%BD%95%E8%AE%BE%E8%AE%A1%E5%90%88%E9%80%82%E7%9A%84%E8%81%94%E5%90%88%E7%B4%A2%E5%BC%95\">2. \u5b9e\u8df5\u4e2d\u7684\u5e94\u7528&#xff1a;\u5982\u4f55\u8bbe\u8ba1\u5408\u9002\u7684\u8054\u5408\u7d22\u5f15<\/h4>\n<p>\u4e3a\u4e86\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\u6700\u5927\u5316\u5229\u7528 \u7d22\u5f15\u8986\u76d6 \u4f18\u52bf&#xff0c;\u8bbe\u8ba1\u5408\u9002\u7684\u8054\u5408\u7d22\u5f15\u81f3\u5173\u91cd\u8981\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5b9e\u8df5\u4e2d\u7684\u8bbe\u8ba1\u5efa\u8bae&#xff1a;<\/p>\n<h5 id=\"a.%20%E7%A1%AE%E4%BF%9D%E7%B4%A2%E5%BC%95%E8%A6%86%E7%9B%96%E6%89%80%E6%9C%89%E6%9F%A5%E8%AF%A2%E5%AD%97%E6%AE%B5\">a. \u786e\u4fdd\u7d22\u5f15\u8986\u76d6\u6240\u6709\u67e5\u8be2\u5b57\u6bb5<\/h5>\n<p>\u5728\u8bbe\u8ba1\u8054\u5408\u7d22\u5f15\u65f6&#xff0c;\u9996\u5148\u8981\u786e\u4fdd\u67e5\u8be2\u6761\u4ef6\u4e2d\u7684\u6240\u6709\u5b57\u6bb5\u90fd\u5305\u542b\u5728\u8054\u5408\u7d22\u5f15\u7684\u8986\u76d6\u8303\u56f4\u5185\u3002\u8fd9\u6837&#xff0c;MySQL \u5c31\u80fd\u5728\u7d22\u5f15\u7684\u53f6\u5b50\u8282\u70b9\u4e2d\u76f4\u63a5\u83b7\u53d6\u6570\u636e&#xff0c;\u907f\u514d\u56de\u8868\u3002<\/p>\n<p>\u4f8b\u5982&#xff0c;\u5bf9\u4e8e\u4ee5\u4e0b\u67e5\u8be2&#xff1a;<\/p>\n<p>SELECT name, age, sex FROM table<br \/>\nWHERE name LIKE &#039;\u5f20%&#039; AND age &#061; 18 AND sex &#061; &#039;\u7537&#039;; <\/p>\n<p>\u5982\u679c\u6211\u4eec\u521b\u5efa\u4e00\u4e2a\u8054\u5408\u7d22\u5f15 (name, age, sex)&#xff0c;\u5219 MySQL \u4f1a\u76f4\u63a5\u4ece\u8054\u5408\u7d22\u5f15\u7684\u53f6\u5b50\u8282\u70b9\u4e2d\u83b7\u53d6\u6240\u6709\u5b57\u6bb5\u7684\u503c&#xff0c;\u65e0\u9700\u56de\u8868\u3002<\/p>\n<h5 id=\"b.%20%E8%80%83%E8%99%91%E6%9C%80%E5%B7%A6%E5%89%8D%E7%BC%80%E5%8E%9F%E5%88%99\">b. \u8003\u8651\u6700\u5de6\u524d\u7f00\u539f\u5219<\/h5>\n<p>MySQL \u7684\u8054\u5408\u7d22\u5f15\u9075\u5faa \u6700\u5de6\u524d\u7f00\u5339\u914d\u539f\u5219\u3002\u4e5f\u5c31\u662f\u8bf4&#xff0c;\u67e5\u8be2\u6761\u4ef6\u5fc5\u987b\u4e0e\u7d22\u5f15\u5b57\u6bb5\u7684\u987a\u5e8f\u4e00\u81f4&#xff0c;\u624d\u80fd\u6709\u6548\u5229\u7528\u8054\u5408\u7d22\u5f15\u3002\u5982\u679c\u67e5\u8be2\u6761\u4ef6\u4e2d\u53ea\u4f7f\u7528\u4e86\u7d22\u5f15\u5b57\u6bb5\u7684\u524d\u51e0\u4e2a&#xff08;\u4f8b\u5982\u53ea\u7528 name \u548c age&#xff09;&#xff0c;\u800c\u4e0d\u5305\u62ec\u540e\u7eed\u5b57\u6bb5&#xff08;\u4f8b\u5982 sex&#xff09;&#xff0c;\u5219 MySQL \u53ea\u80fd\u5229\u7528\u8054\u5408\u7d22\u5f15\u4e2d\u7684\u90e8\u5206\u5b57\u6bb5\u3002<\/p>\n<p>\u56e0\u6b64&#xff0c;\u521b\u5efa\u8054\u5408\u7d22\u5f15\u65f6&#xff0c;\u5e94\u6839\u636e\u5e38\u7528\u67e5\u8be2\u7684\u5b57\u6bb5\u987a\u5e8f\u6765\u5b89\u6392\u7d22\u5f15\u5b57\u6bb5&#xff0c;\u4ee5\u786e\u4fdd\u67e5\u8be2\u65f6\u80fd\u591f\u987a\u5229\u547d\u4e2d\u7d22\u5f15\u3002<\/p>\n<h5 id=\"c.%20%E9%81%BF%E5%85%8D%E5%86%97%E4%BD%99%E7%9A%84%E7%B4%A2%E5%BC%95%E8%AE%BE%E8%AE%A1\">c. \u907f\u514d\u5197\u4f59\u7684\u7d22\u5f15\u8bbe\u8ba1<\/h5>\n<p>\u867d\u7136\u8054\u5408\u7d22\u5f15\u53ef\u4ee5\u63d0\u9ad8\u67e5\u8be2\u6027\u80fd&#xff0c;\u4f46\u4e0d\u5e94\u968f\u610f\u521b\u5efa\u5197\u4f59\u7684\u8054\u5408\u7d22\u5f15\u3002\u4f8b\u5982&#xff0c;\u5982\u679c\u5df2\u7ecf\u6709\u4e00\u4e2a (name, age) \u7684\u8054\u5408\u7d22\u5f15&#xff0c;\u518d\u521b\u5efa\u4e00\u4e2a (name, age, sex) \u7684\u8054\u5408\u7d22\u5f15\u5c31\u53ef\u80fd\u663e\u5f97\u5197\u4f59\u3002\u8981\u6839\u636e\u5177\u4f53\u7684\u67e5\u8be2\u9700\u6c42&#xff0c;\u5408\u7406\u9009\u62e9\u5b57\u6bb5\u5e76\u907f\u514d\u8fc7\u591a\u7684\u8054\u5408\u7d22\u5f15\u3002<\/p>\n<h5 id=\"d.%20%E9%81%BF%E5%85%8D%E5%9C%A8%E8%81%94%E5%90%88%E7%B4%A2%E5%BC%95%E4%B8%AD%E4%BD%BF%E7%94%A8%E8%BE%83%E5%A4%A7%E5%AD%97%E6%AE%B5\">d. \u907f\u514d\u5728\u8054\u5408\u7d22\u5f15\u4e2d\u4f7f\u7528\u8f83\u5927\u5b57\u6bb5<\/h5>\n<p>\u5982\u679c\u67d0\u4e9b\u5b57\u6bb5\u7684\u957f\u5ea6\u8f83\u5927&#xff08;\u4f8b\u5982 TEXT \u7c7b\u578b\u6216\u957f VARCHAR \u5b57\u6bb5&#xff09;&#xff0c;\u90a3\u4e48\u5b83\u4eec\u4e0d\u9002\u5408\u4f5c\u4e3a\u8054\u5408\u7d22\u5f15\u7684\u7ec4\u6210\u90e8\u5206\u3002\u957f\u5b57\u6bb5\u4f1a\u5bfc\u81f4\u6bcf\u4e2a\u7d22\u5f15\u9879\u5360\u7528\u8f83\u5927\u7a7a\u95f4&#xff0c;\u5f71\u54cd\u67e5\u8be2\u6027\u80fd&#xff0c;\u5e76\u589e\u52a0\u78c1\u76d8 I\/O \u548c\u5185\u5b58\u4f7f\u7528\u3002\u5e94\u5c3d\u91cf\u907f\u514d\u5c06\u5927\u5b57\u6bb5\u653e\u5165\u8054\u5408\u7d22\u5f15\u4e2d\u3002<\/p>\n<h3 id=\"%EF%BC%88%E4%B8%89%EF%BC%89%E7%B4%A2%E5%BC%95%E4%B8%8B%E6%8E%A8%EF%BC%9A%E6%8F%90%E5%8D%87%E6%9F%A5%E8%AF%A2%E6%95%88%E7%8E%87\">&#xff08;\u4e09&#xff09;\u7d22\u5f15\u4e0b\u63a8&#xff1a;\u63d0\u5347\u67e5\u8be2\u6548\u7387<\/h3>\n<p>\u7d22\u5f15\u4e0b\u63a8&#xff08;Index Condition Pushdown&#xff0c;ICP&#xff09;&#xff0c;\u8be5\u673a\u5236\u901a\u8fc7\u5c06\u67e5\u8be2\u6761\u4ef6\u7684\u8fc7\u6ee4\u64cd\u4f5c\u4ece MySQL \u670d\u52a1\u5668\u5c42\u63a8\u9001\u5230\u5b58\u50a8\u5f15\u64ce\u5c42&#xff0c;\u663e\u8457\u51cf\u5c11\u4e86\u5185\u5b58\u4e2d\u7684\u6570\u636e\u52a0\u8f7d\u91cf&#xff0c;\u4ece\u800c\u63d0\u5347\u4e86\u67e5\u8be2\u6027\u80fd\u3002\u6211\u4eec\u5c06\u8be6\u7ec6\u8bb2\u89e3\u7d22\u5f15\u4e0b\u63a8\u7684\u5de5\u4f5c\u539f\u7406&#xff0c;\u7ed3\u5408\u5b9e\u9645\u5e94\u7528\u793a\u4f8b&#xff0c;\u5206\u6790\u5982\u4f55\u5229\u7528\u5b83\u4e0e\u8054\u5408\u7d22\u5f15\u7ed3\u5408&#xff0c;\u63d0\u9ad8\u67e5\u8be2\u6548\u7387&#xff0c;\u5c24\u5176\u662f\u5728\u9ad8\u5e76\u53d1\u3001\u5927\u6570\u636e\u91cf\u7684\u573a\u666f\u4e2d\u3002<\/p>\n<h4 id=\"1.%20%E4%BB%80%E4%B9%88%E6%98%AF%E7%B4%A2%E5%BC%95%E4%B8%8B%E6%8E%A8%EF%BC%88Index%20Condition%20Pushdown%EF%BC%89%EF%BC%9F\">1. \u4ec0\u4e48\u662f\u7d22\u5f15\u4e0b\u63a8&#xff08;Index Condition Pushdown&#xff09;&#xff1f;<\/h4>\n<p>\u7d22\u5f15\u4e0b\u63a8\u662f MySQL \u4e2d\u7684\u4e00\u9879\u67e5\u8be2\u4f18\u5316\u6280\u672f&#xff0c;\u5b83\u5c06\u67e5\u8be2\u6761\u4ef6\u7684\u8fc7\u6ee4\u64cd\u4f5c\u4ece \u670d\u52a1\u5668\u5c42 \u63a8\u9001\u5230 \u5b58\u50a8\u5f15\u64ce\u5c42&#xff0c;\u4f7f\u5f97\u5b58\u50a8\u5f15\u64ce\u53ef\u4ee5\u5728\u8bfb\u53d6\u6570\u636e\u65f6\u5c31\u5b8c\u6210\u6761\u4ef6\u7b5b\u9009&#xff0c;\u4ece\u800c\u51cf\u5c11\u4e0d\u5fc5\u8981\u7684\u6570\u636e\u52a0\u8f7d\u3002\u8fd9\u6837&#xff0c;\u5b58\u50a8\u5f15\u64ce\u53ea\u4f1a\u5c06\u7b26\u5408\u67e5\u8be2\u6761\u4ef6\u7684\u6570\u636e\u8fd4\u56de\u7ed9 MySQL \u670d\u52a1\u5668&#xff0c;\u663e\u8457\u964d\u4f4e\u5185\u5b58\u548c\u78c1\u76d8 I\/O \u7684\u5f00\u9500\u3002<\/p>\n<p>\u4f20\u7edf\u67e5\u8be2\u4e2d\u7684\u6570\u636e\u52a0\u8f7d\u6d41\u7a0b\u662f&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u670d\u52a1\u5668\u5c42\u751f\u6210\u67e5\u8be2\u6267\u884c\u8ba1\u5212\u5e76\u901a\u8fc7\u7d22\u5f15\u5b9a\u4f4d\u6570\u636e&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u6570\u636e\u9875\u52a0\u8f7d\u5230\u5185\u5b58&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u670d\u52a1\u5668\u5c42\u518d\u6b21\u8fdb\u884c\u6761\u4ef6\u8fc7\u6ee4&#xff0c;\u7b5b\u9009\u7b26\u5408\u6761\u4ef6\u7684\u6570\u636e\u3002<\/p>\n<\/li>\n<\/ul>\n<p>\u800c \u7d22\u5f15\u4e0b\u63a8 \u5c06\u7b2c\u4e8c\u6b65\u7684\u6761\u4ef6\u8fc7\u6ee4\u64cd\u4f5c\u63d0\u524d\u5230\u5b58\u50a8\u5f15\u64ce\u8fdb\u884c\u3002\u901a\u8fc7\u63d0\u524d\u7b5b\u9009&#xff0c;\u5b58\u50a8\u5f15\u64ce\u53ea\u5c06\u7b26\u5408\u6761\u4ef6\u7684\u6570\u636e\u884c\u52a0\u8f7d\u5230\u5185\u5b58&#xff0c;\u4ece\u800c\u51cf\u5c11\u4e86\u5927\u91cf\u4e0d\u5fc5\u8981\u7684\u6570\u636e\u4f20\u8f93\u548c\u5904\u7406\u8fc7\u7a0b\u3002<\/p>\n<h4 id=\"2.%C2%A0%E7%B4%A2%E5%BC%95%E4%B8%8B%E6%8E%A8%E4%B8%8E%E8%81%94%E5%90%88%E7%B4%A2%E5%BC%95%E7%9A%84%E7%BB%93%E5%90%88\">2.\u00a0\u7d22\u5f15\u4e0b\u63a8\u4e0e\u8054\u5408\u7d22\u5f15\u7684\u7ed3\u5408<\/h4>\n<h5 id=\"2.1%20%E8%81%94%E5%90%88%E7%B4%A2%E5%BC%95%E4%B8%8E%E7%B4%A2%E5%BC%95%E4%B8%8B%E6%8E%A8%E7%9A%84%E4%BC%98%E5%8A%BF%E7%BB%93%E5%90%88\">2.1 \u8054\u5408\u7d22\u5f15\u4e0e\u7d22\u5f15\u4e0b\u63a8\u7684\u4f18\u52bf\u7ed3\u5408<\/h5>\n<p>\u8054\u5408\u7d22\u5f15\u4e0e\u7d22\u5f15\u4e0b\u63a8\u7684\u7ed3\u5408\u4f7f\u5f97\u67e5\u8be2\u4f18\u5316\u66f4\u52a0\u9ad8\u6548\u3002\u5047\u8bbe\u6211\u4eec\u6709\u4e00\u4e2a\u8054\u5408\u7d22\u5f15 (name, age)&#xff0c;\u5e76\u4e14\u67e5\u8be2\u6761\u4ef6\u6b63\u597d\u662f\u5173\u4e8e\u8fd9\u4e24\u4e2a\u5b57\u6bb5\u7684\u7b5b\u9009&#xff1a;<\/p>\n<p>SELECT name, age FROM users WHERE name &#061; &#039;\u5f20\u5f66\u5cf0&#039; AND age &#061; 30; <\/p>\n<ul>\n<li>\n<p>\u7d22\u5f15\u4e0b\u63a8\u4f1a\u4f7f\u5f97 MySQL \u5728\u5b58\u50a8\u5f15\u64ce\u5c42\u5b8c\u6210\u6761\u4ef6 name &#061; &#039;\u5f20\u5f66\u5cf0&#039; AND age &#061; 30 \u7684\u7b5b\u9009&#xff0c;\u800c\u4e0d\u662f\u5728\u67e5\u8be2\u6267\u884c\u540e\u518d\u7b5b\u9009\u3002<\/p>\n<\/li>\n<li>\n<p>\u8054\u5408\u7d22\u5f15\u5c06\u4e24\u4e2a\u5b57\u6bb5\u5b58\u50a8\u5728\u540c\u4e00\u4e2a\u7d22\u5f15\u7ed3\u6784\u4e2d&#xff0c;\u4f7f\u5f97 MySQL \u53ef\u4ee5\u76f4\u63a5\u5728\u7d22\u5f15\u5c42\u5b8c\u6210\u6570\u636e\u8fc7\u6ee4&#xff0c;\u65e0\u9700\u626b\u63cf\u6574\u4e2a\u6570\u636e\u9875\u3002<\/p>\n<\/li>\n<\/ul>\n<p>\u901a\u8fc7\u7ed3\u5408\u8054\u5408\u7d22\u5f15&#xff0c;\u7d22\u5f15\u4e0b\u63a8\u4e0d\u4ec5\u80fd\u63d0\u9ad8\u67e5\u8be2\u6548\u7387&#xff0c;\u8fd8\u80fd\u5927\u5e45\u51cf\u5c11\u6570\u636e\u52a0\u8f7d\u91cf\u548c\u56de\u8868\u64cd\u4f5c&#xff0c;\u7279\u522b\u662f\u5728\u5927\u578b\u6570\u636e\u8868\u4e2d&#xff0c;\u80fd\u591f\u663e\u8457\u63d0\u5347\u67e5\u8be2\u6027\u80fd\u3002<\/p>\n<h5 id=\"2.2%20%E7%A4%BA%E4%BE%8B%E6%BC%94%E7%A4%BA%EF%BC%9A%E8%81%94%E5%90%88%E7%B4%A2%E5%BC%95%E4%B8%8E%E7%B4%A2%E5%BC%95%E4%B8%8B%E6%8E%A8\">2.2 \u793a\u4f8b\u6f14\u793a&#xff1a;\u8054\u5408\u7d22\u5f15\u4e0e\u7d22\u5f15\u4e0b\u63a8<\/h5>\n<p>\u8003\u8651\u5982\u4e0b\u67e5\u8be2&#xff1a;<\/p>\n<p>SELECT name, age FROM users WHERE name LIKE &#039;\u5f20%&#039; AND age &#061; 30; <\/p>\n<p>\u5982\u679c\u5728 users \u8868\u4e0a\u521b\u5efa\u4e86\u4e00\u4e2a (name, age) \u8054\u5408\u7d22\u5f15&#xff0c;\u4e14\u5f00\u542f\u4e86\u7d22\u5f15\u4e0b\u63a8&#xff0c;\u5219\u6267\u884c\u6b65\u9aa4\u5982\u4e0b&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u7d22\u5f15\u626b\u63cf&#xff1a;MySQL \u901a\u8fc7\u8054\u5408\u7d22\u5f15 (name, age) \u8fdb\u884c\u626b\u63cf&#xff0c;\u5e76\u6839\u636e name LIKE &#039;\u5f20%&#039; \u548c age &#061; 30 \u7684\u6761\u4ef6\u5728\u5b58\u50a8\u5f15\u64ce\u5c42\u5b8c\u6210\u8fc7\u6ee4&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u6570\u636e\u52a0\u8f7d&#xff1a;\u53ea\u6709\u7b26\u5408\u67e5\u8be2\u6761\u4ef6\u7684\u8bb0\u5f55&#xff08;\u5373 name &#061; &#039;\u5f20%&#039; \u4e14 age &#061; 30&#xff09;\u4f1a\u88ab\u52a0\u8f7d\u5230\u5185\u5b58&#xff0c;\u5176\u4ed6\u4e0d\u76f8\u5173\u7684\u8bb0\u5f55\u4f1a\u88ab\u76f4\u63a5\u8df3\u8fc7\u3002<\/p>\n<\/li>\n<\/ul>\n<p>\u5728\u8fd9\u4e00\u8fc7\u7a0b\u4e2d&#xff0c;\u7d22\u5f15\u4e0b\u63a8\u51cf\u5c11\u4e86\u5bf9\u4e0d\u7b26\u5408\u67e5\u8be2\u6761\u4ef6\u7684\u6570\u636e\u7684\u52a0\u8f7d&#xff0c;\u4ece\u800c\u63d0\u9ad8\u4e86\u67e5\u8be2\u901f\u5ea6\u3002<\/p>\n<h4 id=\"3.%C2%A0%E7%B4%A2%E5%BC%95%E4%B8%8B%E6%8E%A8%E7%9A%84%E5%B7%A5%E4%BD%9C%E5%8E%9F%E7%90%86%E4%B8%8E%E5%AE%9E%E7%8E%B0\">3.\u00a0\u7d22\u5f15\u4e0b\u63a8\u7684\u5de5\u4f5c\u539f\u7406\u4e0e\u5b9e\u73b0<\/h4>\n<h5 id=\"3.1%20%E7%B4%A2%E5%BC%95%E4%B8%8B%E6%8E%A8%E5%A6%82%E4%BD%95%E5%87%8F%E5%B0%91%E7%A3%81%E7%9B%98I%2FO\">3.1 \u7d22\u5f15\u4e0b\u63a8\u5982\u4f55\u51cf\u5c11\u78c1\u76d8I\/O<\/h5>\n<p>\u7d22\u5f15\u4e0b\u63a8\u80fd\u591f\u51cf\u5c11\u78c1\u76d8 I\/O&#xff0c;\u56e0\u4e3a\u5b83\u907f\u514d\u4e86\u5728\u5185\u5b58\u4e2d\u52a0\u8f7d\u4e0d\u7b26\u5408\u6761\u4ef6\u7684\u6570\u636e\u3002\u901a\u5e38&#xff0c;\u5728\u6ca1\u6709\u7d22\u5f15\u4e0b\u63a8\u7684\u60c5\u51b5\u4e0b&#xff0c;MySQL \u4f1a\u5c06\u6574\u4e2a\u6570\u636e\u9875\u52a0\u8f7d\u5230\u5185\u5b58\u4e2d&#xff0c;\u7136\u540e\u5728\u670d\u52a1\u5668\u5c42\u8fdb\u884c\u6761\u4ef6\u8fc7\u6ee4\u3002\u800c\u5728\u7d22\u5f15\u4e0b\u63a8\u7684\u60c5\u51b5\u4e0b&#xff0c;\u5b58\u50a8\u5f15\u64ce\u4ec5\u52a0\u8f7d\u7b26\u5408\u67e5\u8be2\u6761\u4ef6\u7684\u6570\u636e\u884c&#xff0c;\u4ece\u800c\u51cf\u5c11\u4e86\u4e0d\u5fc5\u8981\u7684\u6570\u636e\u52a0\u8f7d\u3002<\/p>\n<p>\u8fd9\u79cd\u4f18\u5316\u5c24\u5176\u5728\u4ee5\u4e0b\u573a\u666f\u4e2d\u6709\u6548&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u8303\u56f4\u67e5\u8be2&#xff1a;\u4f8b\u5982&#xff0c;\u67e5\u8be2 age &gt; 30 \u7684\u8bb0\u5f55\u65f6&#xff0c;\u7d22\u5f15\u4e0b\u63a8\u53ef\u4ee5\u76f4\u63a5\u5728\u5b58\u50a8\u5f15\u64ce\u5c42\u7b5b\u9009\u51fa\u7b26\u5408\u6761\u4ef6\u7684\u8bb0\u5f55&#xff0c;\u800c\u4e0d\u9700\u8981\u52a0\u8f7d\u6574\u4e2a\u6570\u636e\u9875&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u590d\u6742\u6761\u4ef6\u67e5\u8be2&#xff1a;\u5982 WHERE name &#061; &#039;\u5f20\u5f66\u5cf0&#039; AND age &gt; 30&#xff0c;\u7d22\u5f15\u4e0b\u63a8\u80fd\u591f\u5c06\u591a\u4e2a\u6761\u4ef6\u8fc7\u6ee4\u64cd\u4f5c\u63d0\u524d\u8fdb\u884c&#xff0c;\u51cf\u5c11\u6570\u636e\u4f20\u8f93\u91cf\u3002<\/p>\n<\/li>\n<\/ul>\n<h5 id=\"3.2%20%E6%80%A7%E8%83%BD%E6%8F%90%E5%8D%87%EF%BC%9A%E6%A1%88%E4%BE%8B%E5%88%86%E6%9E%90\">3.2 \u6027\u80fd\u63d0\u5347&#xff1a;\u6848\u4f8b\u5206\u6790<\/h5>\n<p>\u5047\u8bbe\u6211\u4eec\u6709\u4e00\u5f20 users \u8868&#xff0c;\u5305\u542b\u4e0a\u767e\u4e07\u6761\u8bb0\u5f55&#xff0c;\u67e5\u8be2\u6761\u4ef6\u4e3a WHERE name LIKE &#039;\u5f20%&#039; AND age &#061; 30&#xff0c;\u5e76\u4e14\u5728 name \u548c age \u5b57\u6bb5\u4e0a\u521b\u5efa\u4e86\u8054\u5408\u7d22\u5f15\u3002\u5728\u542f\u7528\u7d22\u5f15\u4e0b\u63a8\u7684\u60c5\u51b5\u4e0b&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u5b58\u50a8\u5f15\u64ce\u4f1a\u63d0\u524d\u6839\u636e name LIKE &#039;\u5f20%&#039; AND age &#061; 30 \u7b5b\u9009\u51fa\u7b26\u5408\u6761\u4ef6\u7684\u8bb0\u5f55&#xff1b;<\/p>\n<\/li>\n<li>\n<p>MySQL \u53ea\u4f1a\u52a0\u8f7d\u7b26\u5408\u6761\u4ef6\u7684\u8bb0\u5f55&#xff0c;\u51cf\u5c11\u4e86\u65e0\u5173\u6570\u636e\u7684\u8bfb\u53d6\u3002<\/p>\n<\/li>\n<\/ul>\n<p>\u8fd9\u4e00\u4f18\u5316\u663e\u8457\u51cf\u5c11\u4e86\u67e5\u8be2\u7684 \u78c1\u76d8 I\/O&#xff0c;\u5c24\u5176\u662f\u5728\u67e5\u8be2\u6761\u4ef6\u8303\u56f4\u8f83\u5e7f\u6216\u6570\u636e\u91cf\u8f83\u5927\u7684\u60c5\u51b5\u4e0b&#xff0c;\u6027\u80fd\u63d0\u5347\u5c24\u4e3a\u660e\u663e\u3002<\/p>\n<h4 id=\"4.%C2%A0%E5%90%AF%E7%94%A8%E5%92%8C%E6%9F%A5%E7%9C%8B%E7%B4%A2%E5%BC%95%E4%B8%8B%E6%8E%A8%E5%8A%9F%E8%83%BD\">4.\u00a0\u542f\u7528\u548c\u67e5\u770b\u7d22\u5f15\u4e0b\u63a8\u529f\u80fd<\/h4>\n<h5 id=\"4.1%20%E5%A6%82%E4%BD%95%E5%90%AF%E7%94%A8%E7%B4%A2%E5%BC%95%E4%B8%8B%E6%8E%A8\">4.1 \u5982\u4f55\u542f\u7528\u7d22\u5f15\u4e0b\u63a8<\/h5>\n<p>\u5728 MySQL 5.6 \u53ca\u4ee5\u4e0a\u7248\u672c&#xff0c;\u7d22\u5f15\u4e0b\u63a8 \u9ed8\u8ba4\u662f\u542f\u7528\u7684&#xff0c;\u4f46\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u68c0\u67e5\u5176\u72b6\u6001&#xff1a;<\/p>\n<p>SHOW VARIABLES LIKE &#039;optimizer_switch&#039;; <\/p>\n<p>\u68c0\u67e5\u7ed3\u679c\u4e2d\u7684 index_condition_pushdown \u53c2\u6570\u662f\u5426\u4e3a ON&#xff0c;\u8868\u793a\u7d22\u5f15\u4e0b\u63a8\u5df2\u542f\u7528\u3002\u5982\u679c\u503c\u4e3a OFF&#xff0c;\u5219\u8bf4\u660e\u8be5\u529f\u80fd\u672a\u542f\u7528\u3002<\/p>\n<h5 id=\"4.2%20%E9%85%8D%E7%BD%AE%E7%B4%A2%E5%BC%95%E4%B8%8B%E6%8E%A8\">4.2 \u914d\u7f6e\u7d22\u5f15\u4e0b\u63a8<\/h5>\n<p>\u82e5\u60f3\u7981\u7528\u7d22\u5f15\u4e0b\u63a8&#xff0c;\u53ef\u4ee5\u5728 MySQL \u914d\u7f6e\u6587\u4ef6\u4e2d\u8bbe\u7f6e\u5982\u4e0b&#xff1a;<\/p>\n<p>[mysqld] optimizer_switch&#061;&#039;index_condition_pushdown&#061;off&#039; <\/p>\n<p>\u6216\u8005\u53ef\u4ee5\u5728\u4f1a\u8bdd\u7ea7\u522b\u8fdb\u884c\u914d\u7f6e&#xff1a;<\/p>\n<p>SET SESSION optimizer_switch&#061;&#039;index_condition_pushdown&#061;off&#039;; <\/p>\n<h2 id=\"%E5%9B%9B%E3%80%81%E8%81%94%E5%90%88%E7%B4%A2%E5%BC%95%E7%9A%84%E8%90%BD%E5%9C%B0%E5%AE%9E%E8%B7%B5\">\u56db\u3001\u8054\u5408\u7d22\u5f15\u7684\u843d\u5730\u5b9e\u8df5<\/h2>\n<p>\u6211\u4eec\u5c06\u7ed3\u5408\u5b9e\u9645\u7684\u4e1a\u52a1\u6162\u67e5\u8be2\u4f18\u5316\u7ecf\u9a8c&#xff0c;\u901a\u8fc7\u4e00\u7cfb\u5217\u6162\u67e5\u8be2\u4f18\u5316\u6848\u4f8b\u6765\u63a2\u8ba8\u8054\u5408\u7d22\u5f15\u7684\u4f7f\u7528\u6ce8\u610f\u4e8b\u9879&#xff0c;\u5e76\u5206\u4eab\u6211\u4eec\u5728\u5b9e\u9645\u5de5\u4f5c\u4e2d\u9047\u5230\u7684\u4e00\u4e9b\u95ee\u9898\u3002\u901a\u8fc7\u8fd9\u4e9b\u6848\u4f8b&#xff0c;\u5927\u5bb6\u5c06\u66f4\u6e05\u695a\u5730\u4e86\u89e3\u5982\u4f55\u5728\u7279\u5b9a\u573a\u666f\u4e0b\u4f7f\u7528\u8054\u5408\u7d22\u5f15\u6765\u63d0\u5347\u67e5\u8be2\u6548\u7387\u3002<\/p>\n<h3 id=\"%EF%BC%88%E4%B8%80%EF%BC%89%E8%81%94%E5%90%88%E7%B4%A2%E5%BC%95%E2%80%9C%E6%9C%80%E5%B7%A6%E5%89%8D%E7%BC%80%E2%80%9D%E5%8E%9F%E5%88%99\">&#xff08;\u4e00&#xff09;\u8054\u5408\u7d22\u5f15\u201c\u6700\u5de6\u524d\u7f00\u201d\u539f\u5219<\/h3>\n<p>\u5728\u8ba8\u8bba MySQL \u8054\u5408\u7d22\u5f15\u65f6&#xff0c;\u6700\u5de6\u524d\u7f00\u5339\u914d\u539f\u5219\u662f\u4e00\u4e2a\u65e0\u6cd5\u56de\u907f\u7684\u8bdd\u9898\u3002\u8be5\u539f\u5219\u6307\u660e\u5728\u68c0\u7d22\u6570\u636e\u65f6&#xff0c;\u67e5\u8be2\u4f1a\u4ece\u8054\u5408\u7d22\u5f15\u7684\u6700\u5de6\u4fa7\u5b57\u6bb5\u5f00\u59cb\u5339\u914d\u3002\u56e0\u6b64&#xff0c;\u5728\u521b\u5efa\u8054\u5408\u7d22\u5f15\u65f6&#xff0c;\u5fc5\u987b\u8003\u8651\u67e5\u8be2\u573a\u666f\u4e2d\u80fd\u591f\u8986\u76d6\u7684\u5b57\u6bb5\u987a\u5e8f\u3002\u63a5\u4e0b\u6765&#xff0c;\u6211\u4eec\u5c06\u901a\u8fc7\u4e00\u4e2a\u793a\u4f8b&#xff0c;\u7ed3\u5408 B&#043;\u6811\u7684\u539f\u7406&#xff0c;\u6765\u89e3\u6790\u4e3a\u4ec0\u4e48\u8054\u5408\u7d22\u5f15\u4f1a\u9075\u5faa\u6700\u5de6\u5339\u914d\u539f\u5219\u3002\u6d4b\u8bd5\u8868\u7ed3\u6784\u5982\u4e0b&#xff1a;<\/p>\n<p>CREATE TABLE &#096;status_test&#096; (<br \/>\n  &#096;id&#096; bigint(20) NOT NULL AUTO_INCREMENT COMMENT &#039;ID&#039;,<br \/>\n  &#096;sku_id&#096; bigint(20) NOT NULL COMMENT &#039;\u5546\u54c1ID&#039;,<br \/>\n  &#096;poi_id&#096; bigint(20) NOT NULL COMMENT &#039;\u95e8\u5e97ID&#039;,<br \/>\n  &#096;date_status&#096; bigint(20) NOT NULL COMMENT &#039;\u662f\u5426\u751f\u6548&#039;,<br \/>\n  &#096;period&#096; varchar(100) NOT NULL COMMENT &#039;\u751f\u6548\u65f6\u95f4\u6bb5&#039;,<br \/>\n  &#096;nums&#096; int(11) NOT NULL DEFAULT &#039;1&#039;,<br \/>\n  &#096;ctime&#096; int(11) NOT NULL COMMENT &#039;\u521b\u5efa\u65f6\u95f4&#039;,<br \/>\n  &#096;utime&#096; int(11) NOT NULL COMMENT &#039;\u4fee\u6539\u65f6\u95f4&#039;,<br \/>\n  PRIMARY KEY (&#096;id&#096;),<br \/>\n  UNIQUE KEY &#096;uniq_sku&#096; (&#096;sku_id&#096;)<br \/>\n) ENGINE&#061;InnoDB AUTO_INCREMENT&#061;1<br \/>\nDEFAULT CHARSET&#061;utf8mb4<br \/>\nCOLLATE&#061;utf8mb4_unicode_ci COMMENT&#061;&#039;SKU\u751f\u6548\u65e5\u671f&#039;; <\/p>\n<p>\u6211\u4eec\u5efa\u7acb&#096;date_status&#096;&#043;&#096;poi_id&#096;&#043;&#096;nums&#096;\u7684\u8054\u5408\u7d22\u5f15&#xff0c;\u6309\u7167\u201c\u6700\u5de6\u5339\u914d\u201d\u539f\u5219\u76f8\u5f53\u4e8e\u6211\u4eec\u5bf9 &#xff08;&#096;date_status&#096;&#xff09;\u3001&#xff08;&#096;date_status&#096;,&#096;poi_id&#096;&#xff09;\u548c&#xff08;&#096;date_status&#096;,&#096;poi_id&#096;,&#096;nums&#096;&#xff09;\u521b\u5efa\u4e86\u7d22\u5f15&#xff0c;\u4f46\u662f\u5e76\u672a\u5bf9&#xff08;&#096;poi_id&#096;&#xff09;\u548c&#xff08;&#096;poi_id&#096;,&#096;nums&#096;&#xff09;\u5efa\u7acb\u7d22\u5f15\u3002<\/p>\n<p>\u63a5\u4e0b\u6765&#xff0c;\u6765\u770b\u4e09\u4e2a\u67e5\u8be2\u8bed\u53e5&#xff1a;<\/p>\n<li>\n<p>SELECT * FROM status_test WHERE poi_id &#061; 607002 LIMIT 100;<\/p>\n<\/li>\n<li>\n<p>SELECT * FROM status_test WHERE date_status &gt; 0 AND poi_id &#061; 607002 LIMIT 100;<\/p>\n<\/li>\n<li>\n<p>SELECT * FROM status_test WHERE date_status &#061; 1 AND poi_id &#061; 607002 LIMIT 100;<\/p>\n<\/li>\n<p>\u4e0a\u8ff0\u4e09\u4e2a\u67e5\u8be2\u8bed\u53e5\u4e2d&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u5bf9\u4e8e\u7b2c\u4e00\u4e2a\u67e5\u8be2 poi_id &#061; 607002&#xff0c;\u7531\u4e8e\u5e76\u6ca1\u6709\u5355\u72ec\u4e3a poi_id \u6216 poi_id, nums \u521b\u5efa\u7d22\u5f15&#xff0c;MySQL \u53ea\u80fd\u6267\u884c\u5168\u8868\u626b\u63cf\u3002\u5c3d\u7ba1\u6211\u4eec\u6709 poi_id \u548c nums \u7684\u8054\u5408\u7d22\u5f15&#xff0c;\u4f46\u7531\u4e8e\u67e5\u8be2\u6761\u4ef6\u6ca1\u6709\u4ece\u8054\u5408\u7d22\u5f15\u7684\u6700\u5de6\u524d\u7f00\u5b57\u6bb5&#xff08;\u5373 date_status&#xff09;\u5f00\u59cb&#xff0c;\u5b83\u65e0\u6cd5\u5229\u7528\u8fd9\u4e2a\u7d22\u5f15\u8fdb\u884c\u6709\u6548\u7684\u67e5\u627e\u3002<\/p>\n<\/li>\n<li>\n<p>\u5bf9\u4e8e\u7b2c\u4e8c\u4e2a\u67e5\u8be2&#xff0c;date_status &gt; 0 AND poi_id &#061; 607002&#xff0c;\u5b83\u80fd\u547d\u4e2d date_status \u7d22\u5f15&#xff0c;\u4f46\u7531\u4e8e\u7d22\u5f15\u662f\u6309\u987a\u5e8f\u4ece\u6700\u5de6\u524d\u7f00\u5f00\u59cb\u5339\u914d\u7684&#xff0c;\u67e5\u8be2\u4f1a\u9996\u5148\u901a\u8fc7 date_status \u7d22\u5f15\u8fc7\u6ee4\u51fa\u7b26\u5408\u6761\u4ef6\u7684\u6570\u636e\u3002\u7136\u540e&#xff0c;\u5c3d\u7ba1 poi_id \u88ab\u67e5\u8be2&#xff0c;\u4f46\u7531\u4e8e poi_id \u662f\u7d22\u5f15\u7684\u7b2c\u4e8c\u4e2a\u5b57\u6bb5&#xff0c;\u5b83\u5e76\u672a\u5b8c\u5168\u5339\u914d\u7d22\u5f15\u7684\u524d\u7f00\u90e8\u5206&#xff0c;\u56e0\u6b64 MySQL \u65e0\u6cd5\u7ee7\u7eed\u4f7f\u7528\u8054\u5408\u7d22\u5f15&#xff0c;\u800c\u662f\u9000\u56de\u5230\u5168\u8868\u626b\u63cf\u3002<\/p>\n<\/li>\n<li>\n<p>\u5bf9\u4e8e\u7b2c\u4e09\u4e2a\u67e5\u8be2&#xff0c;date_status &#061; 1 AND poi_id &#061; 607002&#xff0c;\u7531\u4e8e\u67e5\u8be2\u5b57\u6bb5\u987a\u5e8f\u4e0e\u8054\u5408\u7d22\u5f15\u7684\u6700\u5de6\u524d\u7f00&#xff08;date_status, poi_id&#xff09;\u5339\u914d&#xff0c;\u56e0\u6b64\u5b83\u80fd\u591f\u5b8c\u5168\u547d\u4e2d\u8be5\u7d22\u5f15&#xff0c;\u5728 date_status \u548c poi_id \u7684\u7d22\u5f15\u4e2d\u76f4\u63a5\u627e\u5230\u6570\u636e&#xff0c;\u65e0\u9700\u56de\u9000\u5230\u5168\u8868\u626b\u63cf\u3002<\/p>\n<\/li>\n<\/ul>\n<p>\u4e0b\u9762\u4eceB&#043;\u6811\u7d22\u5f15\u89d2\u5ea6\u5206\u6790\u5982\u4e0b&#xff0c;\u5bf9\u4e8e\u67e5\u8be21\u548c\u67e5\u8be22\u7d22\u5f15\u67e5\u8be2\u8fc7\u7a0b\u5982\u4e0b&#xff1a;<\/p>\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"261\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250810101451-6898711be5353.png\" width=\"800\" \/><\/p>\n<p>\u53ef\u4ee5\u770b\u5230&#xff0c;\u901a\u8fc7date_status\u8303\u56f4\u8fc7\u6ee4\u4e4b\u540e&#xff0c;\u5728\u547d\u4e2d\u8303\u56f4\u5185\u6570\u636e&#xff0c;poi_id\u5e76\u975e\u6709\u5e8f(\u56fe\u4e2d\u7ea2\u8272\u5b57\u6bb5)&#xff0c;\u56e0\u6b64\u65e0\u6cd5\u901a\u8fc7\u7d22\u5f15\u76f4\u63a5\u8fc7\u6ee4&#xff0c;\u9700\u8981\u5c06\u8303\u56f4\u5185\u6570\u636e\u5168\u90e8\u904d\u5386\u626b\u63cf\u3002<\/p>\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"261\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250810101452-6898711c7bc8a.png\" width=\"800\" \/><\/p>\n<p>\u5bf9\u4e8e\u67e5\u8be23\u7d22\u5f15\u67e5\u8be2\u8fc7\u7a0b\u5982\u4e0a\u56fe\u6240\u793a&#xff0c;\u901a\u8fc7date_status &#061; 1\u7684\u6570\u636e\u8fdb\u884c\u8fc7\u6ee4\u67e5\u8be2&#xff0c;\u5728\u7ed3\u679c\u96c6\u4e2dpoi_id\u5c40\u90e8\u6709\u5e8f(\u56fe\u4e2d\u7ea2\u8272\u5b57\u6bb5)&#xff0c;\u56e0\u6b64\u53ef\u4ee5\u901a\u8fc7&#096;poi_id&#096;\u7d22\u5f15\u76f4\u63a5\u8fc7\u6ee4\u548c\u67e5\u8be2&#xff0c;\u4e5f\u5373\u547d\u4e2d\u8054\u5408\u7d22\u5f15\u3002\u6700\u5de6\u524d\u7f00\u5339\u914d\u539f\u5219\u7684\u6838\u5fc3\u4e3a\u901a\u8fc7\u5de6\u4fa7\u524d\u7f00\u8fc7\u6ee4\u67e5\u8be2\u5230\u7684\u6570\u636e&#xff0c;\u5bf9\u53f3\u4fa7\u7684\u67e5\u8be2\u6765\u8bf4\u662f\u5c40\u90e8\u6709\u5e8f\u7684\u3001\u80fd\u591f\u901a\u8fc7\u7d22\u5f15\u7ed3\u6784\u68c0\u7d22\u7684\u3002<\/p>\n<p>\u9664\u4e86\u5728\u7b80\u5355\u67e5\u8be2\u4e2d&#xff0c;\u6ee1\u8db3\u6700\u5de6\u5339\u914d\u53ef\u4ee5\u63d0\u5347\u67e5\u8be2\u6548\u7387&#xff1b;\u5728\u5305\u542b\u6392\u5e8f\u7684\u67e5\u8be2&#xff0c;\u4e5f\u53ef\u4ee5\u901a\u8fc7\u6ee1\u8db3\u8054\u5408\u7d22\u5f15\u7684\u6700\u5de6\u5339\u914d\u6765\u63d0\u5347\u67e5\u8be2\u6548\u7387\u3002\u6bd4\u8f83\u7b80\u5355\u7684\u573a\u666f\u4e3a&#xff1a;\u6761\u4ef6\u8fc7\u6ee4\u4e3a\u5e38\u91cf\u8fc7\u6ee4&#xff0c;\u5e76\u4e14order by\u5b57\u6bb5\u80fd\u591f\u914d\u5408\u5e38\u91cf\u8fc7\u6ee4\u6ee1\u8db3\u6700\u5de6\u524d\u7f00&#xff0c;\u5219\u53ef\u4ee5\u901a\u8fc7\u8054\u5408\u7d22\u5f15\u4f18\u5316\u6392\u5e8f\u6027\u80fd&#xff1b;<\/p>\n<p>CREATE TABLE &#096;ad_poi_date_status_copy&#096; (<br \/>\n  &#096;id&#096; bigint(20) NOT NULL AUTO_INCREMENT COMMENT &#039;ID&#039;,<br \/>\n  &#096;sku_id&#096; bigint(20) NOT NULL COMMENT &#039;\u5546\u54c1ID&#039;,<br \/>\n  &#096;poi_id&#096; bigint(20) NOT NULL COMMENT &#039;\u95e8\u5e97ID&#039;,<br \/>\n  &#096;date_status&#096; bigint(20) NOT NULL COMMENT &#039;\u662f\u5426\u751f\u6548&#039;,<br \/>\n  &#096;period&#096; varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT &#039;\u751f\u6548\u65f6\u95f4\u6bb5&#039;,<br \/>\n  &#096;nums&#096; bigint(20) NOT NULL DEFAULT &#039;123456&#039; COMMENT &#039;\u6ce8\u91ca&#039;,<br \/>\n  &#096;ctime&#096; int(11) NOT NULL COMMENT &#039;\u521b\u5efa\u65f6\u95f4&#039;,<br \/>\n  &#096;utime&#096; int(11) NOT NULL COMMENT &#039;\u4fee\u6539\u65f6\u95f4&#039;,<br \/>\n  PRIMARY KEY (&#096;id&#096;),<br \/>\n  KEY &#096;idx_poi_nums_status&#096; (&#096;poi_id&#096;,&#096;nums&#096;,&#096;date_status&#096;)<br \/>\n) ENGINE&#061;InnoDB AUTO_INCREMENT&#061;428091624<br \/>\nDEFAULT CHARSET&#061;utf8mb4 COLLATE&#061;utf8mb4_unicode_ci COMMENT&#061;&#039;SKU\u751f\u6548\u65e5\u671f&#039;; <\/p>\n<p>\u5982\u679c\u8868\u7ed3\u6784&#xff0c;\u5efa\u7acb\u4e86 (&#096;poi_id&#096;,&#096;nums&#096;,&#096;date_status&#096;) \u8054\u5408\u7d22\u5f15&#xff0c;\u5219\u4e0b\u8ff0\u8bed\u53e5a)\u3001b)\u53ef\u4ee5\u901a\u8fc7\u8054\u5408\u7d22\u5f15\u6765\u68c0\u7d22\u548c\u6392\u5e8f&#xff1b;<\/p>\n<p>a) select * from ad_poi_date_status_copy<br \/>\nwhere poi_id &#061; 607002 order by nums;<\/p>\n<p>b) select * from ad_poi_date_status_copy<br \/>\nwhere poi_id &#061; 607002 order by nums,date_status;  <\/p>\n<p>\u53e6\u5916&#xff0c;\u5982\u679c\u8fc7\u6ee4\u6761\u4ef6\u4e0d\u662f\u5e38\u91cf&#xff0c;\u4f46\u662forder by\u4e2d\u5217\u80fd\u591f\u6ee1\u8db3\u8054\u5408\u7d22\u5f15\u7684\u6700\u5de6\u524d\u7f00&#xff0c;\u4e5f\u662f\u53ef\u4ee5\u901a\u8fc7\u8be5\u8054\u5408\u7d22\u5f15\u6765\u63d0\u5347\u6392\u5e8f\u6027\u80fd\u7684&#xff0c;\u793a\u4f8b\u5982\u4e0b&#xff1a;<\/p>\n<p>c) select * from ad_poi_date_status_copy<br \/>\nwhere poi_id &gt; 606999 order by wm_poi_id,nums; <\/p>\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"338\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250810101453-6898711d15fe3.png\" width=\"800\" \/><\/p>\n<p>\u800c\u5bf9\u4e8e\u8bed\u53e5d)\u548c\u8bed\u53e5e)&#xff0c;&#xff08;&#096;poi_id&#096;,&#096;nums&#096;,&#096;date_status&#096;&#xff09;\u8054\u5408\u7d22\u5f15\u7684\u751f\u6548\u60c5\u51b5\u662f\u600e\u6837\u7684\u5462&#xff1f;\u6211\u4eec\u53c8\u9700\u8981\u600e\u4e48\u521b\u5efa\u7d22\u5f15\u6765\u4f18\u5316\u6211\u4eec\u7684\u67e5\u8be2\u6548\u7387\u5462&#xff1f;<\/p>\n<p>d) select \/*!40001 SQL_NO_CACHE *\/ * from ad_poi_date_status_copy<br \/>\nwhere poi_id &#061; 607002 and date_status &gt; 34043232555<br \/>\norder by nums desc limit 100;<\/p>\n<p>e) select \/*!40001 SQL_NO_CACHE *\/ * from ad_poi_date_status_copy<br \/>\nwhere poi_id &#061; 607002 and nums &gt; 331133<br \/>\norder by date_status desc limit 100; <\/p>\n<p>\u5bf9\u4e8e\u8bed\u53e5d)\u6765\u8bf4&#xff0c;&#xff08;&#096;poi_id&#096;,&#096;nums&#096;,&#096;date_status&#096;&#xff09;\u7684\u8054\u5408\u7d22\u5f15\u76f8\u5f53\u4e8e\u5728&#096;poi_id&#096;\u548c&#096;nums&#096;\u5217\u4e0a\u9762\u5efa\u7acb\u7d22\u5f15&#xff0c;\u5219\u67e5\u8be2\u8fc7\u7a0b\u4e2d&#xff0c;\u9996\u5148\u901a\u8fc7poi_id\u8fc7\u6ee4\u7b26\u5408\u67e5\u8be2\u6761\u4ef6\u7684\u8bb0\u5f55&#xff0c;\u518d\u5bf9&#096;date_status&#096;\u8fdb\u884c\u8fc7\u6ee4&#xff0c;\u6b64\u65f6\u65e0\u6cd5\u8d70\u5230\u7d22\u5f15&#xff1b;\u6700\u540e\u5728\u67e5\u8be2\u5230\u7684\u5b50\u96c6\u4e0a\u8fdb\u884c\u6392\u5e8f&#xff0c;\u6b64\u65f6\u7531\u4e8e\u6392\u5e8f\u5b57\u6bb5\u662f&#096;nums&#096;&#xff0c;&#xff08;&#096;poi_id&#096;,&#096;nums&#096;,&#096;date_status&#096;&#xff09;\u7d22\u5f15&#xff0c;\u5728&#096;poi_id&#096;\u76f8\u540c\u7684\u60c5\u51b5\u4e0b&#xff0c;&#096;nums&#096;\u6709\u5e8f&#xff0c;\u4e5f\u5373\u53ef\u4ee5\u8d70&#096;nums&#096;\u7d22\u5f15&#xff1b;<\/p>\n<p>\u5176\u6267\u884cexplain\u7ed3\u679c\u5982\u4e0b&#xff1a;<\/p>\n<table>\n<tbody>\n<tr>\n<p>id<\/p>\n<p>select_type<\/p>\n<p>table<\/p>\n<p>partitions<\/p>\n<p>type<\/p>\n<p>possible_keys<\/p>\n<p>key<\/p>\n<p>key_len<\/p>\n<p>ref<\/p>\n<p>rows<\/p>\n<p>filtered<\/p>\n<p>Extra<\/p>\n<\/tr>\n<tr>\n<td>\n<p>1<\/p>\n<\/td>\n<td>\n<p>SIMPLE<\/p>\n<\/td>\n<td>\n<p>ad_poi_date_status_copy<\/p>\n<\/td>\n<td>\n<p>NULL<\/p>\n<\/td>\n<td>\n<p>ref<\/p>\n<\/td>\n<td>\n<p>idx_poi_nums_status<\/p>\n<\/td>\n<td>\n<p>idx_poi_nums_status<\/p>\n<\/td>\n<td>\n<p>8<\/p>\n<\/td>\n<td>\n<p>const<\/p>\n<\/td>\n<td>\n<p>186388<\/p>\n<\/td>\n<td>\n<p>33.33<\/p>\n<\/td>\n<td>\n<p>Using where<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u901a\u8fc7Extra\u4fe1\u606f\u53ef\u4ee5\u770b\u51fa&#xff0c;order by\u64cd\u4f5c\u7701\u7565\u4e86\u5355\u72ec\u6392\u5e8f\u52a8\u4f5c&#xff08;\u672a\u51fa\u73b0Using filesort\u5173\u952e\u5b57&#xff09;&#xff0c;\u4e5f\u5373\u5229\u7528\u4e86\u7d22\u5f15\u7684\u6709\u5e8f\u6027\u3002<\/p>\n<p>\u5bf9\u4e8e\u8bed\u53e5e)\u6765\u8bf4&#xff0c;&#xff08;&#096;poi_id&#096;,&#096;nums&#096;,&#096;date_status&#096;&#xff09;\u7684\u8054\u5408\u7d22\u5f15\u4e5f\u76f8\u5f53\u4e8e\u662f\u5728&#096;poi_id&#096;\u548c&#096;nums&#096;\u5217\u4e0a\u9762\u5efa\u7acb\u7d22\u5f15&#xff0c;\u8fc7\u6ee4\u67e5\u8be2\u65f6\u8d70&#096;poi_id&#096;\u548c&#096;nums&#096;\u7d22\u5f15\u8fc7\u6ee4\u4e0d\u7b26\u5408\u6761\u4ef6\u7684\u8bb0\u5f55&#xff1b;\u7531\u4e8enums\u662f\u4e00\u4e2a\u8303\u56f4\u67e5\u8be2&#xff0c;\u6b64\u65f6\u8fc7\u6ee4\u7ed3\u679c\u5b50\u96c6\u4e2d&#096;date_status&#096;\u4e0d\u662f\u5b8c\u5168\u6709\u5e8f\u7684&#xff0c;\u6b64\u65f6order by\u64cd\u4f5c\u9700\u8981\u5355\u72ec\u8fdb\u884c\u6392\u5e8f&#xff0c;b)\u8bed\u53e5\u6267\u884cexplain\u7ed3\u679c\u5982\u4e0b&#xff1a;<\/p>\n<table>\n<tr>idselect_typetablepartitionstypepossible_keyskeykey_lenrefrowsfilteredExtra<\/tr>\n<tbody>\n<tr>\n<td>1<\/td>\n<td>SIMPLE<\/td>\n<td>ad_poi_date_status_copy<\/td>\n<td>NULL<\/td>\n<td>range<\/td>\n<td>idx_poi_nums_status<\/td>\n<td>idx_poi_nums_status<\/td>\n<td>16<\/td>\n<td>NULL<\/td>\n<td>203372<\/td>\n<td>100%<\/td>\n<td>Using index condition; Using filesort<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<ul>\n<li>\n<p>\u26a0\ufe0f \u8bf4\u660e&#xff1a;\u867d\u7136\u4f7f\u7528\u4e86\u8054\u5408\u7d22\u5f15&#xff0c;\u4f46\u7531\u4e8e nums &gt; &#8230; \u662f\u8303\u56f4\u67e5\u8be2&#xff0c;\u5bfc\u81f4\u5728\u7d22\u5f15\u7ed3\u6784\u4e2d date_status \u7684\u6709\u5e8f\u6027\u5931\u6548&#xff0c;\u65e0\u6cd5\u5229\u7528\u7d22\u5f15\u8fdb\u884c\u6392\u5e8f&#xff0c;\u56e0\u6b64\u6267\u884c\u4e2d\u9700\u989d\u5916 filesort&#xff0c;\u6027\u80fd\u8f83\u5dee\u3002<\/p>\n<\/li>\n<\/ul>\n<p>\u5bf9\u6bd4\u8bed\u53e5d)\u548c\u8bed\u53e5e)\u7684\u6267\u884c\u6548\u7387&#xff0c;\u8bed\u53e5a)\u6267\u884c\u65f6\u95f4\u5927\u6982\u4e3a2ms&#xff0c;\u8bed\u53e5b)\u6267\u884c\u65f6\u95f4\u5927\u6982600ms\u3002<\/p>\n<table>\n<tr>\u5e8f\u53f7duration (\u79d2)SQL \u8bed\u53e5\u6458\u8981<\/tr>\n<tbody>\n<tr>\n<td>a)<\/td>\n<td>0.001702<\/td>\n<td>where poi_id &#061; 607002 and date_status &gt; &#8230; order by nums desc limit 100<\/td>\n<\/tr>\n<tr>\n<td>b)<\/td>\n<td>0.589737<\/td>\n<td>where poi_id &#061; 607002 and nums &gt; &#8230; order by date_status desc limit 100<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u4f46\u662f\u8fd9\u5e76\u4e0d\u610f\u5473\u7740&#xff0c;\u7c7b\u4f3c\u6b64\u7c7b\u67e5\u8be2&#xff0c;order by\u4e0d\u5355\u72ec\u6392\u5e8f&#xff08;\u4e5f\u5373\u5229\u7528\u7d22\u5f15\u6392\u5e8f&#xff09;\u5c31\u4e00\u5b9a\u662f\u66f4\u9ad8\u6548\u7684\u67e5\u8be2&#xff1b;\u540c\u6837\u7684\u8868\u4ee5\u53ca\u7d22\u5f15\u7ed3\u6784&#xff0c;\u5982\u4e0b\u8bed\u53e5f)\u548c\u8bed\u53e5g)&#xff1a;<\/p>\n<p>f) select \/*!40001 SQL_NO_CACHE *\/ * from ad_poi_date_status_copy<br \/>\nwhere poi_id &#061; 607002 and date_status &gt; 999007069921<br \/>\norder by nums desc limit 100;<br \/>\n\u200b<br \/>\ng) select \/*!40001 SQL_NO_CACHE *\/ * from ad_poi_date_status_copy<br \/>\nwhere poi_id &#061; 607002 and nums &gt; 678092599<br \/>\norder by date_status desc limit 100; <\/p>\n<p>explain\u6267\u884c\u7ed3\u679c\u548c\u6267\u884c\u65f6\u95f4\u5206\u522b\u5982\u4e0b&#xff1a;<\/p>\n<p>&#x1f4ca; \u6267\u884c\u8ba1\u5212\u8868\u683c&#xff08;\u8bed\u53e5 f&#xff09;<\/p>\n<table>\n<tr>idselect_typetablepartitionstypepossible_keyskeykey_lenrefrowsfilteredExtra<\/tr>\n<tbody>\n<tr>\n<td>1<\/td>\n<td>SIMPLE<\/td>\n<td>ad_poi_date_status_copy<\/td>\n<td>NULL<\/td>\n<td>ref<\/td>\n<td>idx_poi_nums_status<\/td>\n<td>idx_poi_nums_status<\/td>\n<td>8<\/td>\n<td>const<\/td>\n<td>186388<\/td>\n<td>33.33%<\/td>\n<td>Using where<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<ul>\n<li>\n<p>\u2705 \u8bf4\u660e&#xff1a;\u67e5\u8be2\u4ee5poi_id \u4e3a\u7b49\u503c\u6761\u4ef6&#xff0c;\u7b26\u5408\u8054\u5408\u7d22\u5f15\u7684\u6700\u5de6\u524d\u7f00\u5339\u914d\u89c4\u5219&#xff0c;\u53ef\u6709\u6548\u5229\u7528\u7d22\u5f15\u8fc7\u6ee4&#xff0c;\u5e76\u4f7f\u7528\u7d22\u5f15\u4e2d\u7684 nums \u5b57\u6bb5\u8fdb\u884c\u6392\u5e8f&#xff0c;\u65e0\u9700 filesort\u3002<\/p>\n<\/li>\n<\/ul>\n<p>&#x1f4ca; \u6267\u884c\u8ba1\u5212\u8868\u683c&#xff08;\u8bed\u53e5 g&#xff09;<\/p>\n<table>\n<tr>idselect_typetablepartitionstypepossible_keyskeykey_lenrefrowsfilteredExtra<\/tr>\n<tbody>\n<tr>\n<td>1<\/td>\n<td>SIMPLE<\/td>\n<td>ad_poi_date_status_copy<\/td>\n<td>NULL<\/td>\n<td>range<\/td>\n<td>idx_poi_nums_status<\/td>\n<td>idx_poi_nums_status<\/td>\n<td>16<\/td>\n<td>NULL<\/td>\n<td>99<\/td>\n<td>100%<\/td>\n<td>Using index condition; Using filesort<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<ul>\n<li>\n<p>\u26a0\ufe0f \u8bf4\u660e&#xff1a;nums &gt; &#8230; \u4e3a\u8303\u56f4\u8fc7\u6ee4&#xff0c;\u56e0\u6b64\u8054\u5408\u7d22\u5f15\u4e2d\u540e\u7eed\u5b57\u6bb5 date_status \u7684\u987a\u5e8f\u6027\u5931\u6548&#xff0c;\u5bfc\u81f4 \u65e0\u6cd5\u4f7f\u7528\u7d22\u5f15\u6392\u5e8f&#xff0c;\u6267\u884c\u4e2d\u89e6\u53d1 filesort\u3002<\/p>\n<\/li>\n<\/ul>\n<p>\u23f1\ufe0f \u5b9e\u9645\u6267\u884c\u8017\u65f6\u5bf9\u6bd4<\/p>\n<table style=\"width:800px\">\n<tr>\u5e8f\u53f7duration (\u79d2)SQL \u8bed\u53e5\u6458\u8981<\/tr>\n<tbody>\n<tr>\n<td>f&#xff09;<\/td>\n<td>0.034625<\/td>\n<td style=\"width:653px\">WHERE poi_id &#061; 607002 AND date_status &gt; &#8230; ORDER BY nums LIMIT 100<\/td>\n<\/tr>\n<tr>\n<td>g&#xff09;<\/td>\n<td>0.001776<\/td>\n<td style=\"width:653px\">WHERE poi_id &#061; 607002 AND nums &gt; &#8230; ORDER BY date_status LIMIT 100<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&#x1f50d; \u7ed3\u8bba\u5206\u6790<\/p>\n<table>\n<tr>\u5bf9\u6bd4\u70b9\u8bed\u53e5 f&#xff09;\u8bed\u53e5 g&#xff09;<\/tr>\n<tbody>\n<tr>\n<td>\u6392\u5e8f\u5b57\u6bb5<\/td>\n<td>ORDER BY nums<\/td>\n<td>ORDER BY date_status<\/td>\n<\/tr>\n<tr>\n<td>\u8fc7\u6ee4\u6761\u4ef6<\/td>\n<td>date_status &gt; &#8230;&#xff08;\u8303\u56f4&#xff09;<\/td>\n<td>nums &gt; &#8230;&#xff08;\u8303\u56f4&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>\u662f\u5426\u5229\u7528\u6392\u5e8f\u7d22\u5f15<\/td>\n<td>\u2705 \u662f&#xff08;\u6392\u5e8f\u5b57\u6bb5\u5728\u8303\u56f4\u6761\u4ef6\u4e4b\u540e&#xff0c;\u987a\u5e8f\u6027\u4fdd\u7559&#xff09;<\/td>\n<td>\u274c \u5426&#xff08;\u6392\u5e8f\u5b57\u6bb5\u987a\u5e8f\u6027\u5931\u6548&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>\u662f\u5426\u89e6\u53d1 filesort<\/td>\n<td>\u274c \u672a\u89e6\u53d1<\/td>\n<td>\u2705 \u89e6\u53d1<\/td>\n<\/tr>\n<tr>\n<td>\u5b9e\u9645\u8017\u65f6<\/td>\n<td>\u7ea6 34ms&#xff08;\u4e2d\u7b49&#xff09;<\/td>\n<td>\u7ea6 1.7ms&#xff08;\u5feb&#xff09;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&#x1f4a1; \u5c3d\u7ba1\u8bed\u53e5 g&#xff09;\u89e6\u53d1\u4e86 filesort&#xff0c;\u4f46\u56e0\u626b\u63cf\u6570\u636e\u91cf\u5c0f&#xff08;\u4ec5 99 \u884c&#xff09;&#xff0c;\u6574\u4f53\u6267\u884c\u8017\u65f6\u4ecd\u7136\u4f4e\u4e8e\u8bed\u53e5 f&#xff09;\u3002\u8fd9\u8bf4\u660e\u5b9e\u9645\u6267\u884c\u65f6\u95f4\u4e0d\u4ec5\u53d6\u51b3\u4e8e\u662f\u5426 filesort&#xff0c;\u8fd8\u4e0e\u6570\u636e\u91cf\u3001\u8fc7\u6ee4\u9009\u62e9\u6027\u7b49\u6709\u5173\u3002<\/p>\n<h3 id=\"%EF%BC%88%E4%BA%8C%EF%BC%89%E5%88%A9%E7%94%A8%E8%81%94%E5%90%88%E7%B4%A2%E5%BC%95%E6%9C%89%E6%95%88%E9%81%BF%E5%85%8D%E7%B4%A2%E5%BC%95%E7%AD%96%E7%95%A5%E5%B9%B2%E6%89%B0\">&#xff08;\u4e8c&#xff09;\u5229\u7528\u8054\u5408\u7d22\u5f15\u6709\u6548\u907f\u514d\u7d22\u5f15\u7b56\u7565\u5e72\u6270<\/h3>\n<p>\u5728\u4e00\u4e2a\u8868\u4e2d\u5373\u4f7f\u6709\u591a\u4e2a\u5355\u5217\u7d22\u5f15&#xff0c;\u5e76\u4e14\u8986\u76d6\u5230\u67e5\u8be2\u8bed\u53e5\u7684\u6240\u6709\u67e5\u8be2\u6761\u4ef6&#xff0c;MySQL\u5728\u67e5\u8be2\u65f6&#xff0c;\u4e5f\u4e0d\u4e00\u5b9a\u4f1a\u9009\u62e9\u591a\u4e2a\u7d22\u5f15&#xff08;\u5e76\u975e\u8bf4\u6570\u636e\u5e93\u67e5\u8be2\u65f6\u53ea\u80fd\u7528\u4e00\u4e2a\u7d22\u5f15&#xff0c;\u4f46\u662f\u4e0e\u53ea\u4f7f\u7528\u4e00\u4e2a\u7d22\u5f15\u7684\u901f\u5ea6\u76f8\u6bd4&#xff0c;\u5206\u6790\u4e24\u4e2a\u7d22\u5f15\u4e8c\u53c9\u6811\u66f4\u8017\u8d39\u65f6\u95f4&#xff0c;\u6240\u4ee5\u591a\u6570\u60c5\u51b5\u4e0b&#xff0c;\u6570\u636e\u67e5\u8be2\u90fd\u53ea\u80fd\u7528\u5230\u4e00\u4e2a\u7d22\u5f15&#xff09;&#xff0c;\u8fd9\u79cd\u60c5\u51b5\u4e0b&#xff0c;\u7531\u4e8eMySQL\u5185\u90e8\u7d22\u5f15\u4f18\u5316\u7b56\u7565\u7684\u5b58\u5728&#xff0c;\u53ef\u80fd\u5bfc\u81f4\u5b9e\u9645\u67e5\u8be2\u547d\u4e2d\u7684\u7d22\u5f15\u4e0e\u6211\u4eec\u9884\u671f\u76f8\u6096&#xff0c;\u800c\u8054\u5408\u7d22\u5f15\u672c\u8eab\u5c31\u662f\u4e00\u4e2aB&#043;\u6811\u7ed3\u6784&#xff0c;\u6240\u4ee5\u5c31\u4e0d\u5b58\u5728\u8981\u9009\u62e9\u54ea\u4e00\u4e2a\u7d22\u5f15\u5b57\u6bb5B&#043;\u6811\u4f5c\u4e3a\u57fa\u7840\u7d22\u5f15\u7ed3\u6784\u6765\u904d\u5386\u7684\u95ee\u9898\u3002<\/p>\n<p>\u5982\u4e0bact_test_table\u8868\u4e2d&#xff0c;\u521b\u5efa\u4e86&#096;aor_id&#096;\u7d22\u5f15&#xff0c;\u4e5f\u521b\u5efa\u4e86&#096;dt&#096;\u7d22\u5f15&#xff1a;<\/p>\n<p>CREATE TABLE &#096;act_test_table&#096; (<br \/>\n  &#096;id&#096; bigint(20) NOT NULL AUTO_INCREMENT COMMENT &#039;\u4e3b\u952e&#039;,<br \/>\n  &#096;poi_id&#096; bigint(20) NOT NULL COMMENT &#039;\u95e8\u5e97ID&#039;,<br \/>\n  &#096;aor_id&#096; bigint(20) NOT NULL COMMENT &#039;\u8702\u7a9dID&#039;,<br \/>\n  &#096;act_info&#096; varchar(500) DEFAULT NULL COMMENT &#039;\u6d3b\u52a8\u4fe1\u606f&#039;,<br \/>\n  &#096;dt&#096; int(11) NOT NULL COMMENT &#039;\u65e5\u671f&#xff0c;20170928\u683c\u5f0f&#039;,<br \/>\n  &#096;ctime&#096; int(11) NOT NULL COMMENT &#039;\u521b\u5efa\u65f6\u95f4&#039;,<br \/>\n  &#096;utime&#096; int(11) NOT NULL COMMENT &#039;\u66f4\u65b0\u65f6\u95f4&#039;,<br \/>\n  PRIMARY KEY (&#096;id&#096;),<br \/>\n  UNIQUE KEY &#096;idx_poi_id_dt&#096; (&#096;poi_id&#096;,&#096;dt&#096;),<br \/>\n  KEY &#096;idx_aor_id&#096; (&#096;aor_id&#096;),<br \/>\n  KEY &#096;idx_dt&#096; (&#096;dt&#096;)<br \/>\n) ENGINE&#061;InnoDB AUTO_INCREMENT&#061;1<br \/>\nDEFAULT CHARSET&#061;utf8mb4 COMMENT&#061;&#039;\u4fe1\u606f\u8868&#039;; <\/p>\n<p>\u4f46\u662f\u4e0b\u8ff0\u8bed\u53e5\u5728\u6267\u884c\u65f6&#xff0c;\u5728\u4e00\u4e9b\u6570\u636e\u60c5\u51b5\u4e0b&#xff0c;\u53ea\u4f1a\u8d70\u5230&#096;aor_id&#096;\u7d22\u5f15&#xff1b;\u5728\u7279\u5b9a\u67e5\u8be2\u6761\u4ef6\u4e0b&#096;aor_id&#096;\u548c&#096;dt&#096;\u4e24\u4e2a\u7d22\u5f15\u90fd\u4f1a\u8d70\u5230\u3002\u800c\u5982\u679c&#xff0c;\u539f\u8868\u4e2d\u589e\u52a0&#096;aor_id&#096; &#043; &#096;dt&#096;\u7684\u8054\u5408\u7d22\u5f15&#xff0c;\u5219\u4e0d\u7ba1\u67e5\u8be2\u6761\u4ef6\u600e\u6837&#xff0c;\u90fd\u4f1a\u8d70\u5230\u8054\u5408\u7d22\u5f15&#xff0c;\u4ece\u800c\u63d0\u9ad8\u67e5\u8be2\u6548\u7387\u3002<\/p>\n<p>SELECT aor_id, dt FROM act_test_table WHERE aor_id &#061; ? AND dt &#061; ?<\/p>\n<p>\/* \u8d70\u4e24\u4e2a\u7d22\u5f15 *\/<br \/>\nEXPLAIN SELECT aor_id, dt<br \/>\nFROM act_test_table<br \/>\nWHERE aor_id &#061; 0  \/* 0 \u6570\u636e\u91cf\u591a *\/<br \/>\nAND dt &#061; 20210601<\/p>\n<p> \/* \u8d70\u4e00\u4e2a\u7d22\u5f15 *\/<br \/>\nEXPLAIN SELECT aor_id, dt<br \/>\nFROM act_test_table<br \/>\nWHERE aor_id &#061; 350<br \/>\nAND dt &#061; 20210601 <\/p>\n<p>\u589e\u52a0\u8054\u5408\u7d22\u5f15\u4e4b\u524d\u5728\u6570\u636e\u5206\u5e03\u4e0d\u540c\u7684\u60c5\u51b5\u4e0b&#xff0c;\u4f1a\u4ea7\u751f\u4e24\u79cd\u60c5\u51b5&#xff1a;<\/p>\n<p>1&#xff09;\u8d70\u5230\u4e86\u4e24\u4e2a\u7d22\u5f15&#xff0c;\u4f7f\u7528&#096;dt&#096;\u548c&#096;aor_id&#096;\u8fdb\u884c\u626b\u63cf\u8fc7\u6ee4&#xff0c;\u7136\u540e\u8fdb\u884cindex merge\u64cd\u4f5c&#xff0c;\u4ece\u626b\u63cf\u884c\u6570\u770b&#xff0c;\u867d\u7136\u8d70\u5230\u4e86\u4e24\u4e2a\u7d22\u5f15&#xff0c;rows\u8fd8\u662f\u5f88\u5927\u3002<\/p>\n<table>\n<tr>idselect_typetablepartitionstypepossible_keyskeykey_lenrefrowsfilteredExtra<\/tr>\n<tbody>\n<tr>\n<td>1<\/td>\n<td>SIMPLE<\/td>\n<td>act_test_table<\/td>\n<td>NULL<\/td>\n<td>index_merge<\/td>\n<td>idx_aor_id,idx_dt<\/td>\n<td>idx_dt,idx_aor_id<\/td>\n<td>4,8<\/td>\n<td>NULL<\/td>\n<td>1,073,015<\/td>\n<td>100%<\/td>\n<td>Using intersect(idx_dt,idx_aor_id); Using where; Using index<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<ul>\n<li>\n<p>\u26a0\ufe0f \u8bf4\u660e&#xff1a;MySQL \u4f7f\u7528\u4e86 Index Merge \u7b56\u7565&#xff0c;\u5bf9 idx_dt \u548c idx_aor_id \u5206\u522b\u8fdb\u884c\u626b\u63cf\u540e\u53d6\u4ea4\u96c6&#xff0c;\u518d\u6267\u884c\u8fc7\u6ee4\u3002<\/p>\n<\/li>\n<li>\n<p>&#x1f50d; \u95ee\u9898&#xff1a;\u867d\u7136\u547d\u4e2d\u591a\u4e2a\u7d22\u5f15&#xff0c;\u4f46\u5408\u5e76\u540e\u4ecd\u626b\u63cf\u4e86\u8d85\u767e\u4e07\u884c&#xff0c;\u6548\u7387\u8f83\u4f4e\u3002<\/p>\n<\/li>\n<\/ul>\n<p>2&#xff09;\u8d70\u4e00\u4e2a\u7d22\u5f15&#xff0c;&#096;aor_id&#096;\u7d22\u5f15<\/p>\n<table>\n<tr>idselect_typetablepartitionstypepossible_keyskeykey_lenrefrowsfilteredExtra<\/tr>\n<tbody>\n<tr>\n<td>1<\/td>\n<td>SIMPLE<\/td>\n<td>act_test_table<\/td>\n<td>NULL<\/td>\n<td>ref<\/td>\n<td>idx_aor_id,idx_dt<\/td>\n<td>idx_aor_id<\/td>\n<td>8<\/td>\n<td>const<\/td>\n<td>3088<\/td>\n<td>23.95%<\/td>\n<td>Using where<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<ul>\n<li>\n<p>\u2705 \u8bf4\u660e&#xff1a;\u6b64\u65f6\u4ec5\u4f7f\u7528 aor_id \u7d22\u5f15\u4f5c\u4e3a\u4e3b\u8fc7\u6ee4\u6761\u4ef6&#xff0c;\u626b\u63cf\u884c\u6570\u663e\u8457\u51cf\u5c11&#xff08;3088 \u884c&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>&#x1f4a1; \u4f18\u52bf&#xff1a;\u867d\u7136\u8fc7\u6ee4\u7cbe\u5ea6\u7a0d\u4f4e&#xff08;23.95%&#xff09;&#xff0c;\u4f46\u626b\u63cf\u4ee3\u4ef7\u8fdc\u4f4e\u4e8e Index Merge \u60c5\u51b5\u3002<\/p>\n<\/li>\n<\/ul>\n<p>\u4e3a\u4f55\u540c\u4e00\u4e2a\u8bed\u53e5\u547d\u4e2d\u7d22\u5f15\u4e0d\u540c&#xff0c;\u6267\u884c\u6548\u7387\u5343\u5dee\u4e07\u522b&#xff0c;\u6211\u4eec\u4ece\u7d22\u5f15\u7ed3\u6784\u5206\u6790\u4e00\u4e0b&#xff1a;<\/p>\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"386\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250810101453-6898711d700ad.png\" width=\"800\" \/><\/p>\n<p>\u7ed3\u5408\u4e0a\u56fe\u6211\u4eec\u9010\u4e2a\u5206\u6790&#xff0c;\u7b2c\u4e00\u79cd\u60c5\u51b5\u4e0b&#xff0c;\u7d22\u5f15\u5b57\u6bb5\u4e3a&#096;dt&#096;\u548c&#096;aor_id&#096;&#xff0c;extra\u5217\u53ef\u4ee5\u770b\u5230\u6709Using intersect&#xff0c;\u4e5f\u5373\u5728\u67e5\u8be2\u65f6&#xff0c;\u9996\u5148\u901a\u8fc7&#096;dt&#096;\u548c&#096;aor_id&#096;\u6267\u884c\u540c\u6b65\u626b\u63cf\u548c\u8fc7\u6ee4&#xff0c;\u7136\u540e\u901a\u8fc7Using intersect\u7b97\u6cd5\u8fdb\u884cindex merge\u64cd\u4f5c\u53d6\u4ea4\u96c6&#xff08;\u8bed\u53e5\u6267\u884c\u6570\u636e\u5982\u56fe\u4e2d\u7ea2\u8272\u7bad\u5934\u6240\u793a&#xff09;&#xff1b;\u800c\u7b2c\u4e8c\u4e2a\u8bed\u53e5&#xff0c;\u53ea\u4f7f\u7528\u4e86&#096;aor_id&#096;\u7d22\u5f15&#xff0c;\u6b64\u65f6\u6267\u884c\u987a\u5e8f\u662f\u6839\u636e&#096;aor_id&#096;\u8fc7\u6ee4\u51fa\u7b26\u5408\u6761\u4ef6\u7684\u8bb0\u5f55&#xff0c;\u4ece\u547d\u4e2d\u8303\u56f4\u7684\u6700\u5de6\u4fa7\u53f6\u5b50\u8282\u70b9&#xff0c;\u987a\u5e8f\u53d6\u51fa\u6570\u636e&#xff0c;\u6bcf\u6761\u6570\u636e\u6839\u636eWHERE\u6761\u4ef6\u4e2d&#096;dt&#096;\u5224\u65ad\u662f\u5426\u5339\u914d&#xff0c;\u5982\u679c\u7b26\u5408WHERE\u6761\u4ef6&#xff0c;\u5219\u53d6\u51fa\u6570\u636e&#xff0c;\u76f4\u5230\u4e0b\u4e00\u6761\u6570\u636e\u7684&#096;aor_id&#096;\u6bd4350\u5927\u4e3a\u6b62&#xff08;\u8bed\u53e5\u6267\u884c\u6570\u636e\u5982\u56fe\u4e2d\u7eff\u8272\u7bad\u5934\u6240\u793a&#xff09;&#xff1b;\u7b2c\u4e00\u79cd\u60c5\u51b5\u4e0b&#xff0c;&#096;dt&#096;\u8fc7\u6ee4\u4e4b\u540e\u547d\u4e2d\u7ea6\u547d\u4e2d20W\u6570\u636e&#xff0c;\u6839\u636e&#096;aor_id&#096;\u8fc7\u6ee4\u540e\u547d\u4e2d700W\u6570\u636e&#xff0c;\u4f18\u5316\u5668\u5224\u65ad\u53d6\u4ea4\u96c6\u7684\u6548\u7387\u9ad8\u4e8e\u904d\u5386700W\u7684\u6570\u636e&#xff08;id\u6709\u5e8f&#xff0c;\u53d6\u4ea4\u96c6\u53ef\u4ee5\u4f7f\u7528dt\u547d\u4e2d\u768420W\u6570\u636e\u5230\u53f3\u4fa7700W\u7684\u6570\u636e\u4e2d\u67e5\u627e&#xff0c;\u7b2c\u4e00\u6b21\u68c0\u7d22\u6309\u7167\u4e8c\u5206\u67e5\u627e\u9700\u898120\u6b21&#043;&#xff0c;\u4f46\u662f\u7531\u4e8e\u6570\u636e\u5de6\u4fa7\u6570\u636e\u6709\u5e8f\u4e14id\u57fa\u672c\u8fde\u7eed&#xff0c;\u540e\u7eed\u7684\u67e5\u627e\u65f6\u95f4\u590d\u6742\u5ea6\u4e3aO(1)&#xff0c;\u56e0\u6b64\u67e5\u8be2\u548c\u53d6\u4ea4\u96c6\u904d\u5386\u6570\u636e\u8fd1\u4f3c\u4e3a\u4e3a20W\u6570\u636e&#xff0c;\u4e14\u53d6\u4ea4\u96c6\u8fc7\u7a0b\u65e0\u9700\u56de\u8868&#xff09;&#xff1b;\u800c\u7b2c\u4e8c\u79cd\u60c5\u51b5\u4e0b&#xff0c;&#096;aor_id&#096;\u547d\u4e2d\u6570\u636e\u53ea\u6709\u51e0\u5343\u6761\u6570\u636e&#xff0c;\u76f4\u63a5\u904d\u5386\u7136\u540e\u5224\u65ad\u662f\u5426\u7b26\u5408\u6761\u4ef6\u7684\u6210\u672c\u66f4\u5c0f\u3002<\/p>\n<p>\u589e\u52a0&#096;aor_id&#096; &#043; &#096;dt&#096;\u7684\u8054\u5408\u7d22\u5f15&#xff1a;<\/p>\n<p>CREATE TABLE &#096;act_test_table&#096; (<br \/>\n  &#096;id&#096; bigint(20) NOT NULL AUTO_INCREMENT COMMENT &#039;\u4e3b\u952e&#039;,<br \/>\n  &#096;poi_id&#096; bigint(20) NOT NULL COMMENT &#039;\u95e8\u5e97ID&#039;,<br \/>\n  &#096;aor_id&#096; bigint(20) NOT NULL COMMENT &#039;\u8702\u7a9dID&#039;,<br \/>\n  &#096;act_info&#096; varchar(500) DEFAULT NULL COMMENT &#039;\u6d3b\u52a8\u4fe1\u606f&#039;,<br \/>\n  &#096;dt&#096; int(11) NOT NULL COMMENT &#039;\u65e5\u671f&#xff0c;20170928\u683c\u5f0f&#039;,<br \/>\n  &#096;ctime&#096; int(11) NOT NULL COMMENT &#039;\u521b\u5efa\u65f6\u95f4&#039;,<br \/>\n  &#096;utime&#096; int(11) NOT NULL COMMENT &#039;\u66f4\u65b0\u65f6\u95f4&#039;,<br \/>\n  PRIMARY KEY (&#096;id&#096;),<br \/>\n  UNIQUE KEY &#096;idx_poi_id_dt&#096; (&#096;poi_id&#096;,&#096;dt&#096;),<br \/>\n  KEY &#096;idx_aor_id&#096; (&#096;aor_id&#096;),<br \/>\n  KEY &#096;idx_dt&#096; (&#096;dt&#096;),<br \/>\n  KEY &#096;idx_aor_id_dt&#096; (&#096;aor_id&#096;,&#096;dt&#096;)<br \/>\n) ENGINE&#061;InnoDB AUTO_INCREMENT&#061;2 DEFAULT CHARSET&#061;utf8mb4 COMMENT&#061;&#039;\u4fe1\u606f\u8868&#039;; <\/p>\n<p>\u901a\u8fc7\u4e3a act_test_table \u6dfb\u52a0\u8054\u5408\u7d22\u5f15 (aor_id, dt) \u540e&#xff0c;\u67e5\u8be2\u8bed\u53e5\u53ef\u76f4\u63a5\u547d\u4e2d\u8be5\u7d22\u5f15&#xff0c;\u6267\u884c\u6548\u7387\u663e\u8457\u63d0\u5347\u3002<\/p>\n<table>\n<tr>idselect_typetablepartitionstypepossible_keyskeykey_lenrefrowsfilteredExtra<\/tr>\n<tbody>\n<tr>\n<td>1<\/td>\n<td>SIMPLE<\/td>\n<td>act_test_table<\/td>\n<td>NULL<\/td>\n<td>ref<\/td>\n<td>idx_aor_id,idx_dt,idx_aor_id_dt<\/td>\n<td>idx_aor_id_dt<\/td>\n<td>12<\/td>\n<td>const,const<\/td>\n<td>385<\/td>\n<td>100%<\/td>\n<td>Using index<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&#x1f50d; \u8bf4\u660e&#xff1a;<\/p>\n<ul>\n<li>\n<p>key&#xff1a;idx_aor_id_dt \u8868\u793a\u547d\u4e2d\u6211\u4eec\u65b0\u5efa\u7684\u8054\u5408\u7d22\u5f15\u3002<\/p>\n<\/li>\n<li>\n<p>type&#xff1a;\u4f7f\u7528 ref \u7c7b\u578b\u8bbf\u95ee\u65b9\u5f0f&#xff0c;\u8868\u793a\u901a\u8fc7\u7d22\u5f15\u7b49\u503c\u5339\u914d&#xff0c;\u6548\u7387\u8f83\u9ad8\u3002<\/p>\n<\/li>\n<li>\n<p>ref&#xff1a;const,const \u8bf4\u660e aor_id \u548c dt \u5747\u53c2\u4e0e\u7d22\u5f15\u8fc7\u6ee4\u3002<\/p>\n<\/li>\n<li>\n<p>rows&#xff1a;\u9884\u4f30\u4ec5\u9700\u626b\u63cf 385 \u884c\u6570\u636e&#xff0c;\u660e\u663e\u4f18\u4e8e Index Merge \u60c5\u51b5\u4e0b\u7684\u767e\u4e07\u7ea7\u626b\u63cf\u3002<\/p>\n<\/li>\n<li>\n<p>Extra&#xff1a;Using index \u8868\u793a\u67e5\u8be2\u4ec5\u4f7f\u7528\u7d22\u5f15\u4e2d\u7684\u6570\u636e&#xff0c;\u65e0\u9700\u56de\u8868&#xff0c;\u5c5e\u4e8e\u8986\u76d6\u7d22\u5f15\u4f18\u5316\u7684\u4e00\u79cd\u4f53\u73b0\u3002<\/p>\n<\/li>\n<\/ul>\n<p>\u589e\u52a0\u8054\u5408\u7d22\u5f15\u7684\u60c5\u51b5\u4e0b&#xff1a;<\/p>\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"3\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250810101454-6898711e51ac6.png\" width=\"800\" \/><\/p>\n<h3 id=\"%EF%BC%88%E4%B8%89%EF%BC%89%E6%95%B0%E6%8D%AE%E6%9E%81%E7%AB%AF%E5%88%86%E5%B8%83%E4%B8%8B%E8%81%94%E5%90%88%E7%B4%A2%E5%BC%95%E7%9A%84%E4%BD%9C%E7%94%A8\">&#xff08;\u4e09&#xff09;\u6570\u636e\u6781\u7aef\u5206\u5e03\u4e0b\u8054\u5408\u7d22\u5f15\u7684\u4f5c\u7528<\/h3>\n<p>\u4e00\u822c\u60c5\u51b5\u4e0b&#xff0c;\u5982\u679cDB\u4e2d\u67d0\u4e00\u4e2a\u5b57\u6bb5\u7684\u679a\u4e3e\u503c\u6570\u91cf\u5f88\u5c0f&#xff0c;\u5219\u4e00\u822c\u4e0d\u5efa\u7acb\u7d22\u5f15&#xff0c;\u4f8b\u5982\u6027\u522b&#xff0c;\u4f46\u662f\u5982\u679c\u6570\u636e\u5206\u5e03\u6bd4\u8f83\u6781\u7aef&#xff0c;\u5728\u4e00\u5b9a\u7684\u4e1a\u52a1\u67e5\u8be2\u573a\u666f\u4e0b&#xff0c;\u5728\u8be5\u5217\u521b\u5efa\u7d22\u5f15\u53ef\u4ee5\u6781\u5927\u7684\u63d0\u9ad8\u67e5\u8be2\u6548\u7387\u3002\u5982\u4e0b\u4e3a\u6211\u4eec\u5728\u4e1a\u52a1\u9047\u5230\u7684\u4e00\u4e2a\u6162\u67e5\u8be2\u8bed\u53e5&#xff1a;<\/p>\n<p> explain SELECT \/*!40001 SQL_NO_CACHE *\/  * FROM p_id_test<br \/>\nWHERE p_id &#061; 44241135 AND status &#061; 0 ;<\/p>\n<p>\u5176\u4e2dp_id_test\u8868\u4e2d\u5927\u6982100W&#043;\u6570\u636e&#xff0c;\u7531\u4e8e\u4e1a\u52a1\u539f\u56e0&#xff0c;\u8868\u4e2dstatus\u5b57\u6bb5\u5206\u5e03\u5982\u4e0b\u8868&#xff0c;\u5b57\u6bb5\u503c\u4e3a1\u5360\u6bd4\u8d85\u8fc790%<\/p>\n<table>\n<tbody>\n<tr>\n<p>status\u5b57\u6bb5\u503c\u679a\u4e3e<\/p>\n<p>\u6570\u636e\u7edf\u8ba1<\/p>\n<\/tr>\n<tr>\n<td>\n<p>1<\/p>\n<\/td>\n<td>\n<p>972089<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>0<\/p>\n<\/td>\n<td>\n<p>30889<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>2<\/p>\n<\/td>\n<td>\n<p>1<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u8868p_id_test\u521d\u59cb\u7ed3\u6784\u4e3a&#xff1a;<\/p>\n<p>CREATE TABLE &#096;p_id_test&#096; (<br \/>\n  &#096;id&#096; int(11) NOT NULL AUTO_INCREMENT COMMENT &#039;\u4e3b\u952e&#039;,<br \/>\n  &#096;p_id&#096; bigint(20) NOT NULL COMMENT &#039;id&#039;,<br \/>\n  &#096;name&#096; varchar(30) NOT NULL COMMENT &#039;\u540d\u79f0&#039;,<br \/>\n  &#096;w_s_id&#096; bigint(20) NOT NULL COMMENT &#039;s_id&#039;,<br \/>\n  &#096;status&#096; int(11) NOT NULL DEFAULT &#039;1&#039; COMMENT &#039;\u72b6\u6001&#039;,<br \/>\n  &#096;ctime&#096; int(11) NOT NULL COMMENT &#039;\u521b\u5efa\u65f6\u95f4&#039;,<br \/>\n  &#096;utime&#096; int(11) NOT NULL COMMENT &#039;\u66f4\u65b0\u65f6\u95f4&#039;,<br \/>\n  PRIMARY KEY (&#096;id&#096;),<br \/>\n  KEY &#096;idx_p_id&#096; (&#096;p_id&#096;),<br \/>\n  KEY &#096;idx_w_s_id&#096; (&#096;w_s_id&#096;)<br \/>\n) ENGINE&#061;InnoDB AUTO_INCREMENT&#061;1 DEFAULT CHARSET&#061;utf8 COMMENT&#061;&#039;\u6d4b\u8bd5\u6570\u636e\u8868&#039;; <\/p>\n<p>\u5728\u6b64\u7d22\u5f15\u7ed3\u6784\u4e0b&#xff0c;\u6267\u884c\u65f6\u95f4\u7ea6\u4e3a800ms&#xff0c;\u6b64\u65f6\u5982\u679c\u589e\u52a0&#096;p_id&#096;\u548c&#096;status&#096;\u7ec4\u5408\u7d22\u5f15&#xff0c;\u540c\u6837\u7684\u8bed\u53e5\u6267\u884c\u65f6\u95f4\u7ea6\u4e3a6-9ms&#xff0c;\u6548\u7387\u63d0\u9ad8100\u500d\u5de6\u53f3&#xff1b;\u6dfb\u52a0&#096;p_id&#096;&#043;&#096;status&#096;\u7ec4\u5408\u7d22\u5f15\u524d\u540e\u7684explain\u7ed3\u679c\u5206\u522b\u5982\u4e0b&#xff1a;<\/p>\n<table>\n<tbody>\n<tr>\n<td>\n<\/td>\n<td>\n<p>id<\/p>\n<\/td>\n<td>\n<p>select_type<\/p>\n<\/td>\n<td>\n<p>table<\/p>\n<\/td>\n<td>\n<p>partitions<\/p>\n<\/td>\n<td>\n<p>type<\/p>\n<\/td>\n<td>\n<p>possible_keys<\/p>\n<\/td>\n<td>\n<p>key<\/p>\n<\/td>\n<td>\n<p>key_len<\/p>\n<\/td>\n<td>\n<p>ref<\/p>\n<\/td>\n<td>\n<p>rows<\/p>\n<\/td>\n<td>\n<p>filtered<\/p>\n<\/td>\n<td>\n<p>Extra<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>\u672a\u52a0\u7d22\u5f15<\/p>\n<\/td>\n<td>\n<p>1<\/p>\n<\/td>\n<td>\n<p>SIMPLE<\/p>\n<\/td>\n<td>\n<p>p_id_test<\/p>\n<\/td>\n<td>\n<p>NULL<\/p>\n<\/td>\n<td>\n<p>ref<\/p>\n<\/td>\n<td>\n<p>idx_p_id<\/p>\n<\/td>\n<td>\n<p>idx_p_id<\/p>\n<\/td>\n<td>\n<p>8<\/p>\n<\/td>\n<td>\n<p>const<\/p>\n<\/td>\n<td>\n<p>375628<\/p>\n<\/td>\n<td>\n<p>10<\/p>\n<\/td>\n<td>\n<p>Using where<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>\u589e\u52a0\u7ec4\u5408\u7d22\u5f15<\/p>\n<\/td>\n<td>\n<p>1<\/p>\n<\/td>\n<td>\n<p>SIMPLE<\/p>\n<\/td>\n<td>\n<p>p_id_test<\/p>\n<\/td>\n<td>\n<p>NULL<\/p>\n<\/td>\n<td>\n<p>ref<\/p>\n<\/td>\n<td>\n<p>idx_p_id,idx_p_id_status<\/p>\n<\/td>\n<td>\n<p>idx_p_id_status<\/p>\n<\/td>\n<td>\n<p>12<\/p>\n<\/td>\n<td>\n<p>const,const<\/p>\n<\/td>\n<td>\n<p>1<\/p>\n<\/td>\n<td>\n<p>100<\/p>\n<\/td>\n<td>\n<p>NULL<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u53ef\u4ee5\u770b\u5230\u547d\u4e2d&#096;p_id&#096;&#043;&#096;status&#096;\u7ec4\u5408\u7d22\u5f15\u7684\u60c5\u51b5\u4e0b&#xff0c;row\u4f1a\u8fdc\u8fdc\u5c11\u4e8e\u672a\u521b\u5efa\u7ec4\u5408\u7d22\u5f15\u7684\u60c5\u51b5&#xff1b;\u6dfb\u52a0&#096;p_id&#096;&#043;&#096;status&#096;\u7ec4\u5408\u7d22\u5f15\u524d\u540e&#096;p_id&#096;\u90fd\u662f\u8d70\u5230\u4e86\u7d22\u5f15\u7684&#xff0c;\u800c&#096;status&#096;\u5b57\u6bb5\u53ea\u6709\u4e09\u4e2a\u503c&#xff0c;\u533a\u5206\u5ea6\u5f88\u4f4e&#xff0c;\u4f46\u662f\u6dfb\u52a0&#096;p_id&#096;&#043;&#096;status&#096;\u7d22\u5f15\u4e4b\u540e\u4e3a\u4ec0\u4e48\u67e5\u8be2\u6548\u7387\u4f1a\u660e\u663e\u63d0\u9ad8&#xff1f;<\/p>\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"298\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250810101455-6898711f92898.png\" width=\"800\" \/><\/p>\n<p>\u7ed3\u5408status\u6570\u636e\u5206\u5e03&#xff0c;\u89c2\u5bdf&#096;p_id&#096;&#043;&#096;status&#096;\u8054\u5408\u7d22\u5f15B&#043;\u6811\u7ed3\u6784&#xff0c;\u53ef\u4ee5\u5f88\u76f4\u89c2\u7684\u770b\u5230&#xff0c;\u5f53\u67e5\u8be2\u6761\u4ef6\u67e5\u8be2\u7684&#096;status&#096;\u4e0d\u4e3a1\u65f6&#xff0c;\u6bcf\u6b21\u67e5\u8be2\u901a\u8fc7&#096;p_id&#096;&#043;&#096;status&#096;\u7d22\u5f15\u53ef\u4ee5\u5c06&#096;p_id&#096;\u547d\u4e2d\u7684\u6570\u636e\u8fc7\u6ee4\u6389\u5f88\u5927\u7684\u4e00\u90e8\u5206&#xff0c;\u547d\u4e2d\u7684\u6570\u636e\u91cf\u5f88\u5c0f&#xff0c;\u7ed3\u5408\u4e1a\u52a1\u4e2d\u67e5\u8be2\u4e2d\u591a\u4e3a\u67e5\u8be2&#096;status&#096;\u4e3a0\u7684\u60c5\u51b5&#xff0c;\u589e\u52a0\u8054\u5408\u7d22\u5f15\u53ef\u4ee5\u8f7b\u6613\u7684\u89e3\u51b3\u4e1a\u52a1\u4e2d\u7684\u6162\u67e5\u8be2\u3002<\/p>\n<h3 id=\"%EF%BC%88%E5%9B%9B%EF%BC%89%E8%81%9A%E5%90%88%E6%93%8D%E4%BD%9C%E5%9C%BA%E6%99%AF\">&#xff08;\u56db&#xff09;\u805a\u5408\u64cd\u4f5c\u573a\u666f<\/h3>\n<p>\u6211\u4eec\u5728\u5bf9group by\u8bed\u53e5\u8fdb\u884c\u67e5\u8be2\u4f18\u5316&#xff0c;\u4e00\u822c\u4f1a\u8bd5\u56fe\u901a\u8fc7\u677e\u6563\u7d22\u5f15\u626b\u63cf&#xff08;loose index scan&#xff09;\u548c\u7d27\u51d1\u7d22\u5f15\u626b\u63cf&#xff08;tight index scan&#xff09;\u6765\u63d0\u9ad8\u8bed\u53e5\u6267\u884c\u6548\u7387\u3002\u5728\u4e0d\u6ee1\u8db3\u677e\u6563\u7d22\u5f15\u626b\u63cf\u548c\u7d27\u51d1\u7d22\u5f15\u626b\u63cf\u7684\u60c5\u51b5\u4e0b&#xff0c;group by\u8bed\u53e5\u9700\u8981\u5148\u626b\u63cf\u6574\u4e2a\u8868&#xff0c;\u63d0\u53d6\u6570\u636e\u521b\u5efa\u4e00\u4e2a\u4e34\u65f6\u8868&#xff0c;\u518d\u6839\u636egroup by\u8bed\u53e5\u4e2d\u6307\u5b9a\u7684\u5217\u8fdb\u884c\u6392\u5e8f&#xff0c;\u6392\u5e8f\u4e4b\u540e\u5c31\u53ef\u4ee5\u627e\u5230\u6240\u6709\u7684\u5206\u7ec4&#xff0c;\u7136\u540e\u6267\u884c\u805a\u96c6\u51fd\u6570&#xff08;\u4f8b\u5982max\u3001min\u7b49&#xff09;&#xff0c;\u8fd9\u4e2a\u8fc7\u7a0b\u5728\u6267\u884c\u8ba1\u5212\u4e2d\u7684\u8868\u73b0\u4e3a\u4f1a\u51fa\u73b0\u7c7b\u4f3c\u201cUsing temporary; Using filesort\u201d\u7684\u5173\u952e\u5b57&#xff1b;\u901a\u8fc7\u677e\u6563\u7d22\u5f15\u626b\u63cf\u548c\u7d27\u51d1\u7d22\u5f15\u626b\u63cf\u6765\u63d0\u9ad8\u8bed\u53e5\u6267\u884c\u6548\u7387&#xff0c;\u4e3b\u8981\u7684\u601d\u8def\u662f\u5e0c\u671b\u5728\u8bfb\u53d6\u7d22\u5f15\u7684\u57fa\u7840\u4e0a\u76f4\u63a5\u5b8c\u6210group by\u64cd\u4f5c&#xff0c;\u4ee5\u8df3\u8fc7\u521b\u5efa\u4e34\u65f6\u8868\u548c\u6392\u5e8f\u64cd\u4f5c&#xff0c;\u7531\u4e8e\u5f88\u591a\u60c5\u51b5\u4e0b&#xff0c;\u6211\u4eec\u7684\u805a\u5408\u64cd\u4f5c\u7684\u5206\u7ec4\u4f9d\u636e\u7684\u5217\u90fd\u6709\u591a\u4e2a&#xff0c;\u8981\u60f3\u4f7f\u7528\u677e\u6563\u7d22\u5f15\u6216\u8005\u7d27\u51d1\u7d22\u5f15&#xff0c;\u9700\u8981\u4ed6\u4eec\u6765\u81ea\u540c\u4e00\u4e2a\u7d22\u5f15&#xff0c;\u4e5f\u5c31\u5fc5\u987b\u914d\u5408\u8054\u5408\u7d22\u5f15\u3002<\/p>\n<p>\u4e0b\u9762\u770b\u4e00\u4e2a\u4f8b\u5b50&#xff1a;<\/p>\n<p>SELECT  \/*!40001 SQL_NO_CACHE *\/ poi_id,date_status,max(nums)<br \/>\nFROM status_test<br \/>\nGROUP BY date_status,poi_id<br \/>\nLIMIT 300 <\/p>\n<p>\u64cd\u4f5c\u6570\u636e\u8868\u7ed3\u6784\u5982\u4e0b&#xff1a;<\/p>\n<p>CREATE TABLE &#096;status_test&#096; (<br \/>\n  &#096;id&#096; bigint(20) NOT NULL AUTO_INCREMENT COMMENT &#039;ID&#039;,<br \/>\n  &#096;sku_id&#096; bigint(20) NOT NULL COMMENT &#039;\u5546\u54c1ID&#039;,<br \/>\n  &#096;poi_id&#096; bigint(20) NOT NULL COMMENT &#039;\u95e8\u5e97ID&#039;,<br \/>\n  &#096;date_status&#096; bigint(20) NOT NULL COMMENT &#039;\u662f\u5426\u751f\u6548&#039;,<br \/>\n  &#096;period&#096; varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT &#039;\u751f\u6548\u65f6\u95f4\u6bb5&#039;,<br \/>\n  &#096;nums&#096; int(11) NOT NULL DEFAULT &#039;1&#039;,<br \/>\n  &#096;ctime&#096; int(11) NOT NULL COMMENT &#039;\u521b\u5efa\u65f6\u95f4&#039;,<br \/>\n  &#096;utime&#096; int(11) NOT NULL COMMENT &#039;\u4fee\u6539\u65f6\u95f4&#039;,<br \/>\n  PRIMARY KEY (&#096;id&#096;),<br \/>\n  UNIQUE KEY &#096;uniq_sku&#096; (&#096;sku_id&#096;),<br \/>\n  KEY &#096;idx_poi&#096; (&#096;poi_id&#096;),<br \/>\n  KEY &#096;idx_date_status&#096; (&#096;date_status&#096;)<br \/>\n) ENGINE&#061;InnoDB AUTO_INCREMENT&#061;1 DEFAULT CHARSET&#061;utf8mb4<br \/>\nCOLLATE&#061;utf8mb4_unicode_ci COMMENT&#061;&#039;SKU\u751f\u6548\u65e5\u671f&#039;; <\/p>\n<p>\u7531\u4e8egroup by\u4e2d\u5b57\u6bb5\u4e0d\u5728\u540c\u4e00\u4e2a\u7d22\u5f15\u4e2d&#xff0c;\u65e0\u6cd5\u4f7f\u7528\u677e\u6563\u7d22\u5f15\u6216\u8005\u7d27\u51d1\u7d22\u5f15&#xff0c;\u5728\u6d4b\u8bd5\u8fc7\u7a0b\u4e2d\u53d1\u73b0\u8bed\u53e5\u6267\u884c\u65f6\u95f4\u5927\u6982\u4e3a3.5s&#xff0c;\u6267\u884cexplain&#xff0c;\u7ed3\u679c\u5982\u4e0b\u8868&#xff0c;Extra\u663e\u793a\u786e\u5b9e\u4f7f\u7528\u4e86\u4e34\u65f6\u8868&#xff0c;\u5e76\u4e14\u6709\u5355\u72ec\u7684\u6392\u5e8f\u64cd\u4f5c\u3002<\/p>\n<table>\n<tbody>\n<tr>\n<p>id<\/p>\n<p>select_type<\/p>\n<p>table<\/p>\n<p>partitions<\/p>\n<p>type<\/p>\n<p>possible_keys<\/p>\n<p>key<\/p>\n<p>key_len<\/p>\n<p>ref<\/p>\n<p>rows<\/p>\n<p>filtered<\/p>\n<p>Extra<\/p>\n<\/tr>\n<tr>\n<td>\n<p>1<\/p>\n<\/td>\n<td>\n<p>SIMPLE<\/p>\n<\/td>\n<td>\n<p>status_test<\/p>\n<\/td>\n<td>\n<p>NULL<\/p>\n<\/td>\n<td>\n<p>ALL<\/p>\n<\/td>\n<td>\n<p>NULL<\/p>\n<\/td>\n<td>\n<p>NULL<\/p>\n<\/td>\n<td>\n<p>NULL<\/p>\n<\/td>\n<td>\n<p>NULL<\/p>\n<\/td>\n<td>\n<p>2095163<\/p>\n<\/td>\n<td>\n<p>100<\/p>\n<\/td>\n<td>\n<p>Using temporary; Using filesort<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u53bb\u6389&#096;poi_id&#096;\u5355\u5217\u7d22\u5f15&#xff0c;\u589e\u52a0&#096;date_status&#096;,&#096;poi_id&#096;,&#096;nums&#096;\u8054\u5408\u7d22\u5f15&#xff0c;\u518d\u6b21\u6267\u884c&#xff0c;\u6267\u884c\u65f6\u95f4\u7ea612ms&#xff0c;\u6267\u884cexplain&#xff0c;\u7ed3\u679c\u5982\u4e0b\u8868&#xff0c;\u677e\u6563\u7d22\u5f15\u626b\u63cf\u751f\u6548&#xff0c;\u626b\u63cf\u884c\u6570\u51cf\u5c1190%&#xff0c;\u6267\u884c\u6548\u7387\u63d0\u9ad8\u8fd1300\u500d\u3002<\/p>\n<table>\n<tbody>\n<tr>\n<p>id<\/p>\n<p>select_type<\/p>\n<p>table<\/p>\n<p>partitions<\/p>\n<p>type<\/p>\n<p>possible_keys<\/p>\n<p>key<\/p>\n<p>key_len<\/p>\n<p>ref<\/p>\n<p>rows<\/p>\n<p>filtered<\/p>\n<p>Extra<\/p>\n<\/tr>\n<tr>\n<td>\n<p>1<\/p>\n<\/td>\n<td>\n<p>SIMPLE<\/p>\n<\/td>\n<td>\n<p>status_test<\/p>\n<\/td>\n<td>\n<p>NULL<\/p>\n<\/td>\n<td>\n<p>range<\/p>\n<\/td>\n<td>\n<p>idx_poi_status_num,idx_status_poi_num<\/p>\n<\/td>\n<td>\n<p>idx_status_poi_num<\/p>\n<\/td>\n<td>\n<p>16<\/p>\n<\/td>\n<td>\n<p>NULL<\/p>\n<\/td>\n<td>\n<p>168054<\/p>\n<\/td>\n<td>\n<p>100<\/p>\n<\/td>\n<td>\n<p>Using index for group-by<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u9996\u5148&#xff0c;\u6211\u4eec\u5927\u81f4\u7684\u6784\u9020\u51fa\u8868\u4e2d&#096;date_status&#096;&#043;&#096;poi_id&#096;&#043;&#096;nums&#096;\u8054\u5408\u7d22\u5f15\u7684B&#043;\u6811\u7ed3\u6784&#xff0c;\u5982\u56fe\u6240\u793a&#xff1a;<\/p>\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"292\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250810101456-689871205e1d1.png\" width=\"800\" \/><\/p>\n<p>\u6848\u4f8b\u4e2d\u8bed\u53e5\u547d\u4e2d&#096;idx_poi_status_num&#096;&#xff0c;\u7531\u4e8e\u8054\u5408\u7d22\u5f15\u7279\u6027&#xff0c;\u5176\u7d22\u5f15\u5217\u6709\u5e8f&#xff0c;\u56e0\u6b64\u5728\u6309\u7167wm_poi_id\u548cdate_status\u5206\u7ec4\u540e&#xff0c;\u80fd\u76f4\u63a5\u901a\u8fc7\u7d22\u5f15\u8ba1\u7b97\u51famax(num)&#xff0c;\u4e0d\u9700\u8981\u53d6\u7684\u53f6\u5b50\u8282\u70b9\u7684\u4e3b\u952e\u7d22\u5f15\u66f4\u4e0d\u9700\u8981\u56de\u8868\u64cd\u4f5c\u3002\u56e0\u6b64\u67e5\u8be2\u6548\u7387\u8fdc\u9ad8\u4e8e\u6ca1\u6709\u672a\u4f7f\u7528\u5230\u7d27\u51d1\u7d22\u5f15\u548c\u677e\u6563\u7d22\u5f15\u7684\u60c5\u51b5\u3002\u805a\u5408\u67e5\u8be2\u8d70\u677e\u6563\u7d22\u5f15\u5f88\u91cd\u8981\u7684\u4e00\u4e2a\u6761\u4ef6\u662fgroup by\u7684\u6240\u6709\u5217\u662f\u8868\u4e2d\u4e00\u4e2a\u7d22\u5f15\u6216\u8005\u8fd9\u4e2a\u7d22\u5f15\u7684\u6700\u5de6\u524d\u7f00&#xff0c;\u5e76\u4e14\u4e0d\u5305\u542b\u8fd9\u4e2a\u7d22\u5f15\u4e4b\u5916\u7684\u5176\u5b83\u5217&#xff0c;\u4e00\u65e6group by\u7684\u5b57\u6bb5\u8d85\u8fc7\u4e00\u4e2a&#xff0c;\u5c31\u5fc5\u7136\u8981\u6c42\u8868\u4e2d\u6709\u7b26\u5408\u6761\u4ef6\u7684\u8054\u5408\u7d22\u5f15&#xff0c;\u5426\u5219\u90fd\u65e0\u6cd5\u8d70\u677e\u6563\u7d22\u5f15\u626b\u63cf\u3002<\/p>\n<h3 id=\"%EF%BC%88%E4%BA%94%EF%BC%89%E5%A4%9A%E8%A1%A8%E5%85%B3%E8%81%94%E6%9F%A5%E8%AF%A2\">&#xff08;\u4e94&#xff09;\u591a\u8868\u5173\u8054\u67e5\u8be2<\/h3>\n<p>\u5728\u591a\u8868\u5173\u8054\u67e5\u8be2\u65f6&#xff0c;MySQL\u53ea\u652f\u6301Nested Loop Join&#xff08;\u5d4c\u5957\u5faa\u73af\u8fde\u63a5&#xff09;\u8fd9\u4e00\u79cdjoin \u7b97\u6cd5\u3002Nested Loop Join\u7b97\u6cd5\u7684\u4e3b\u8981\u601d\u60f3\u662f&#xff0c;\u5c06\u9a71\u52a8\u8868\u7684\u6570\u636e\u7ed3\u679c\u96c6\u4f5c\u4e3a\u5faa\u73af\u57fa\u7840\u6570\u636e&#xff0c;\u7136\u540e\u5faa\u73af\u7684\u4ece\u9a71\u52a8\u8868\u7684\u6570\u636e\u7ed3\u679c\u96c6\u4e2d\u6bcf\u6b21\u53d6\u4e00\u6761\u6570\u636e\u4f5c\u4e3a\u4e0b\u4e00\u4e2a\u8868\u7684\u8fc7\u6ee4\u6761\u4ef6&#xff0c;\u8fdb\u884c\u6570\u636e\u67e5\u8be2&#xff0c;\u518d\u5c06\u4e24\u4e2a\u8868\u7684\u67e5\u8be2\u7ed3\u679c\u5408\u5e76\u8d77\u6765&#xff1b;\u5982\u679c\u6709\u591a\u4e2a\u8868\u8fdb\u884cjoin\u67e5\u8be2&#xff0c;\u5219\u4ee5\u6b64\u7c7b\u63a8\u7684&#xff0c;\u5c06\u524d\u9762\u7684\u8868\u7684\u67e5\u8be2\u7ed3\u679c\u96c6\u4f5c\u4e3a\u5faa\u73af\u57fa\u7840\u6570\u636e&#xff0c;\u6bcf\u884c\u5faa\u73af\u7684\u5230\u5173\u8054\u7684\u4e0b\u4e00\u4e2a\u8868\u4e2d\u5339\u914d\u3002<\/p>\n<h4 id=\"id-5.1MySQLjoin\u7b97\u6cd5\">1. MySQL join\u7b97\u6cd5<\/h4>\n<p>\u5728MySQL\u7684\u5b9e\u73b0\u4e2d&#xff0c;Nested Loop Join\u7684\u5b9e\u73b0\u4e3b\u8981\u4e3a Index Nested Loop Join\u7b97\u6cd5\u548c Block Nested Loop Join\u7b97\u6cd5\u4e24\u79cd\u3002<\/p>\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"272\" src=\"2025-08-10shcccjeybas.png\" width=\"800\" \/><\/p>\n<h5 id=\"1%EF%B8%8F%E2%83%A3%20Index%20Nested%20Loop%20Join%EF%BC%88%E7%B4%A2%E5%BC%95%E5%B5%8C%E5%A5%97%E5%BE%AA%E7%8E%AF%E8%BF%9E%E6%8E%A5%EF%BC%89\">1\ufe0f\u20e3 Index Nested Loop Join&#xff08;\u7d22\u5f15\u5d4c\u5957\u5faa\u73af\u8fde\u63a5&#xff09;<\/h5>\n<p>\u5b9a\u4e49&#xff1a;\u5bf9\u5916\u5c42\u8868&#xff08;\u9a71\u52a8\u8868&#xff09;\u7684\u6bcf\u4e00\u884c\u6570\u636e&#xff0c;\u4ece\u5185\u5c42\u8868\u4e2d\u4f7f\u7528\u7d22\u5f15\u67e5\u627e\u5339\u914d\u7684\u884c\u3002<\/p>\n<p>\u4f7f\u7528\u573a\u666f&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u5185\u5c42\u8868\u7684\u8fde\u63a5\u5b57\u6bb5\u4e0a\u5b58\u5728\u5408\u9002\u7684\u7d22\u5f15&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u6570\u636e\u91cf\u9002\u4e2d\u6216\u9009\u62e9\u6027\u8f83\u9ad8&#xff08;\u5373\u8fc7\u6ee4\u6548\u679c\u597d&#xff09;&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u901a\u5e38\u662f MySQL \u9ed8\u8ba4\u4f18\u5148\u9009\u62e9\u7684 Join \u65b9\u5f0f\u3002<\/p>\n<\/li>\n<\/ul>\n<h5 id=\"2%EF%B8%8F%E2%83%A3%20Block%20Nested%20Loop%20Join%EF%BC%88%E5%9D%97%E5%B5%8C%E5%A5%97%E5%BE%AA%E7%8E%AF%E8%BF%9E%E6%8E%A5%EF%BC%89\">2\ufe0f\u20e3 Block Nested Loop Join&#xff08;\u5757\u5d4c\u5957\u5faa\u73af\u8fde\u63a5&#xff09;<\/h5>\n<p>\u5b9a\u4e49&#xff1a;MySQL \u4f1a\u5c06\u5916\u5c42\u8868\u7684\u4e00\u6279\u8bb0\u5f55&#xff08;block&#xff09;\u8bfb\u5165\u5185\u5b58&#xff0c;\u5e76\u5bf9\u8fd9\u4e9b\u8bb0\u5f55\u6784\u9020\u4e34\u65f6\u54c8\u5e0c\u7ed3\u6784&#xff0c;\u518d\u6279\u91cf\u4e0e\u5185\u5c42\u8868\u8fdb\u884c\u6bd4\u8f83\u3002<\/p>\n<p>\u4f7f\u7528\u573a\u666f&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u5185\u5c42\u8868\u6ca1\u6709\u5408\u9002\u7684\u7d22\u5f15&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u53ef\u5206\u914d\u8f83\u5927 join_buffer_size&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u901a\u5e38\u5728\u5185\u5c42\u8868\u65e0\u6cd5\u901a\u8fc7\u7d22\u5f15\u9ad8\u6548\u8bbf\u95ee\u65f6\u89e6\u53d1&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u4e5f\u79f0\u4e3a BNL Join\u3002<\/p>\n<\/li>\n<\/ul>\n<p>&#x1f4cc; \u603b\u7ed3\u5bf9\u6bd4<\/p>\n<table>\n<tr>\u7279\u6027Index Nested Loop JoinBlock Nested Loop Join<\/tr>\n<tbody>\n<tr>\n<td>\u662f\u5426\u4f7f\u7528\u7d22\u5f15<\/td>\n<td>\u2705 \u662f<\/td>\n<td>\u274c \u5426<\/td>\n<\/tr>\n<tr>\n<td>\u662f\u5426\u4f9d\u8d56 join_buffer<\/td>\n<td>\u274c \u5426<\/td>\n<td>\u2705 \u662f<\/td>\n<\/tr>\n<tr>\n<td>\u5185\u5c42\u8868\u8bbf\u95ee\u65b9\u5f0f<\/td>\n<td>\u57fa\u4e8e\u7d22\u5f15\u67e5\u627e<\/td>\n<td>\u5168\u8868\u626b\u63cf<\/td>\n<\/tr>\n<tr>\n<td>\u5916\u5c42\u8868\u8bbf\u95ee\u65b9\u5f0f<\/td>\n<td>\u884c\u904d\u5386&#xff08;\u5355\u884c\u6216\u5757&#xff09;<\/td>\n<td>\u5757\u904d\u5386<\/td>\n<\/tr>\n<tr>\n<td>\u6027\u80fd\u8868\u73b0<\/td>\n<td>\u9ad8&#xff08;\u4f9d\u8d56\u7d22\u5f15\u548c\u5916\u5c42\u8868\u5927\u5c0f&#xff09;<\/td>\n<td>\u8f83\u4f4e&#xff08;\u6570\u636e\u91cf\u5927\u4f1a\u975e\u5e38\u6162&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>\u907f\u514d\u65b9\u5f0f<\/td>\n<td>\u786e\u4fdd\u5185\u5c42\u8868\u8fde\u63a5\u5b57\u6bb5\u6709\u7d22\u5f15<\/td>\n<td>\u6dfb\u52a0\u7d22\u5f15\/\u9650\u5236 join_buffer \u4f7f\u7528<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u5982\u679c\u5339\u914d\u8868&#xff08;\u4e5f\u53eb\u975e\u9a71\u52a8\u8868&#xff09;\u91cc\u6ca1\u6709\u7d22\u5f15\u6765\u505ajoin\u5173\u8054&#xff0c;\u5c31\u4f1a\u8d70Block Nested Loop Join\u7b97\u6cd5&#xff0c;\u5373\u4ece\u4e0a\u56fe\u53ef\u4ee5\u770b\u51fa&#xff0c;\u4f1a\u628a\u9a71\u52a8\u8868\u6240\u6709join\u76f8\u5173\u7684\u5217\u5148\u7f13\u5b58\u5230join buffer\u4e2d&#xff0c;\u7136\u540e\u6279\u91cf\u4e0e\u5339\u914d\u8868\u8fdb\u884c\u5339\u914d\u3002\u8fd9\u79cd\u5339\u914d\u65b9\u5f0f\u9996\u5148\u6d6a\u8d39\u5185\u5b58&#xff0c;\u56e0\u4e3a\u9700\u8981\u4e34\u65f6\u7f13\u7a7a\u95f4&#xff0c;\u5bfc\u81f4\u9a71\u52a8\u8868join\u5217\u591a\u7684\u65f6\u5019&#xff0c;\u5bfc\u81f4\u6d88\u8017\u5f88\u591a\u5185\u5b58&#xff0c;\u5bf9MySQL server\u7aef\u5185\u5b58\u9020\u6210\u5f88\u5927\u538b\u529b&#xff0c;\u4e5f\u4f1a\u540c\u65f6\u6324\u5360MySQL\u6b63\u5e38\u7d22\u5f15\u7a7a\u95f4\u3002\u5176\u6b21&#xff0c;\u5339\u914d\u6548\u7387\u6bd4Index Nested Loop Join\u7b97\u6cd5\u4f4e&#xff0c;\u56e0\u4e3aBlock Nested Loop Join\u7b97\u6cd5\u7684\u5339\u914d\u65b9\u5f0f\u672c\u8d28\u8fd8\u662f\u4ecejoin buffer\u91cc\u4e00\u4e2a\u4e00\u4e2a\u8ddf\u5339\u914d\u8868\u91cc\u7684\u5b57\u6bb5\u5339\u914d&#xff0c;\u53ea\u662f\u5b83\u662f\u4ece\u5185\u5b58\u91cc\u8bfb\u53d6\u51fa\u6765&#xff0c;\u6bd4\u6700\u539f\u59cb\u7684Simple Nested Loop\u7b97\u6cd5\u4ece\u78c1\u76d8\u91cc\u67e5\u8be2\u51fa\u6765\u6548\u7387\u9ad8\u800c\u5df2\u3002<\/p>\n<p>\u8fd9\u91ccMySQL\u5bf9join\u64cd\u4f5c&#xff0c;\u4f1a\u6839\u636ejoin\u5de6\u53f3\u4e24\u5f20\u8868\u7684\u6570\u636e\u91cf\u51b3\u5b9a\u54ea\u4e2a\u4f5c\u4e3a\u9a71\u52a8\u8868&#xff08;\u5373\u4e00\u822c\u6570\u636e\u91cf\u8f83\u5c0f\u7684\u9a71\u52a8\u8868&#xff09;\u3002<\/p>\n<p>\u7efc\u4e0a\u6240\u8ff0&#xff0c;\u4f7f\u7528join\u7684\u65f6\u5019&#xff0c;\u4e00\u5b9a\u8981\u5728\u5339\u914d\u8868\u91ccjoin\u5173\u8054\u5b57\u6bb5\u52a0\u4e0a\u7d22\u5f15&#xff0c;\u5426\u5219\u968f\u7740\u6570\u636e\u91cf\u53d8\u5927&#xff0c;\u6027\u80fd\u4f1a\u8d8a\u6765\u8d8a\u6162\u3002<\/p>\n<h4 id=\"id-5.2\u591a\u8868\u67e5\u8be2\u4e2d\u8054\u5408\u7d22\u5f15\u63d0\u5347join\u7b97\u6cd5\u67e5\u8be2\u6548\u7387\">2. \u591a\u8868\u67e5\u8be2\u4e2d\u8054\u5408\u7d22\u5f15\u63d0\u5347join\u7b97\u6cd5\u67e5\u8be2\u6548\u7387<\/h4>\n<p>\u4e0b\u9762\u7684\u793a\u4f8b\u53ef\u4ee5\u770b\u4e00\u4e0b\u8054\u5408\u7d22\u5f15\u5728join\u67e5\u8be2\u4e2d\u600e\u6837\u63d0\u5347join\u7b97\u6cd5\u7684\u67e5\u8be2\u6548\u7387&#xff1a;<\/p>\n<p>SELECT config.id, config.open_type, config.spread_date, config.status, config.category, config.ad_pos, config.ctime<br \/>\nFROM config_test_table config<br \/>\nLEFT JOIN area_test_table area ON area.role_config_id &#061; config.id AND area.open_type &#061; config.open_type <\/p>\n<p>\u8868area_test_table\u6ca1\u6709\u521b\u5efa\u7d22\u5f15\u65f6&#xff0c;\u5982\u4e0b\u6240\u793a&#xff0c;\u4f1a\u53d6\u51faconfig_test_table\u8868\u4e2d\u6bcf\u4e00\u6761\u8bb0\u5f55&#xff0c;\u5faa\u73af\u4e0earea_test_table\u4e2d\u7684\u6bcf\u4e00\u6761\u8bb0\u5f55\u8fdb\u884c\u5bf9\u6bd4&#xff1b;<\/p>\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"206\" src=\"2025-08-1035t214miif2.png\" width=\"500\" \/><\/p>\n<p>\u7ed9area_test_table\u589e\u52a0role_config_id&#043;open_type\u7684\u8054\u5408\u7d22\u5f15&#xff0c;\u8be5\u67e5\u8be2\u4e2djion\u7b97\u6cd5\u4f1a\u63d0\u5347\u4e3aIndex Nested Loop Join\u7b97\u6cd5&#xff0c;\u5176\u5339\u914d\u8fc7\u7a0b\u8fc7\u5982\u56fe&#xff0c;config_test_table\u8868\u8bb0\u5f55&#xff0c;\u4f1a\u5faa\u73af\u7684\u5728area_test_table\u7684\u8054\u5408\u7d22\u5f15\u7684B&#043;\u6811\u4e2d\u5339\u914d&#xff0c;\u5f53\u5339\u914d\u6210\u529f\u65f6&#xff0c;\u4f1a\u6839\u636e\u7d22\u5f15\u53f6\u5b50\u8282\u70b9\u7684\u4e3b\u952eid&#xff0c;\u518d\u4ece\u5339\u914d\u8868\u4e2d\u53d6\u51fa\u5176\u4ed6\u5b57\u6bb5\u503c&#xff1b;\u5176\u67e5\u8be2\u7684\u6548\u7387\u5c06\u5927\u5927\u63d0\u5347\u3002<\/p>\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"378\" src=\"2025-08-101pkfx3tejyr.png\" width=\"800\" \/><\/p>\n<p>\u5728\u591a\u8868\u5173\u8054\u67e5\u8be2\u4e2d\u4f7f\u7528\u8054\u5408\u7d22\u5f15&#xff0c;\u9700\u8981\u6ce8\u610f\u54ea\u4e2a\u8868\u4e3a\u9a71\u52a8\u8868&#xff0c;\u54ea\u4e2a\u4e3a\u5339\u914d\u8868&#xff0c;\u5982\u4e0b&#xff1a;<\/p>\n<p>SELECT config.id, config.open_type, config.spread_date, config.status, config.category, config.ad_pos, config.ctime<br \/>\nFROM area_test_table area<br \/>\nLEFT JOIN config_test_table config ON area.role_config_id &#061; config.id AND area.open_type &#061; config.open_type <\/p>\n<p>\u867d\u7136\u8bed\u53e5\u5199\u7684\u662farea_test_table\u5728\u5de6\u4fa7&#xff0c;config_test_table\u5728\u53f3\u4fa7&#xff0c;\u5b9e\u9645\u56e0\u4e3aconfig_test_table\u8fdc\u8fdc\u5c0f\u4e8earea_test_table\u8868\u6570\u636e&#xff0c;MySQL\u5728\u6267\u884c\u65f6&#xff0c;\u4f18\u5316\u5668\u4f1a\u9009\u62e9config_test_table\u8868\u4e3a\u9a71\u52a8\u8868&#xff0c;\u5982\u679c\u53ea\u5728config_test_table\u8868\u4e0a\u521b\u5efa\u7d22\u5f15&#xff0c;\u800c\u672a\u5728\u5339\u914d\u8868\u521b\u5efa\u7d22\u5f15&#xff0c;\u5219\u4e0a\u8bed\u53e5\u4e0e\u6ca1\u6709\u7d22\u5f15\u5b9e\u9645\u662f\u76f8\u540c\u7684&#xff0c;\u6267\u884c\u65f6\u65e0\u6cd5\u8d70Index Nested Loop Join\u4f18\u5316\u3002<\/p>\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"282\" src=\"2025-08-10iad04hnxkyo.png\" width=\"800\" \/><\/p>\n<p>\u5206\u6790\u5982\u56fe&#xff0c;\u867d\u7136config_test_table\u521b\u5efa\u4e86\u7d22\u5f15&#xff0c;\u4f46\u662f\u7531\u4e8econfig_test_table\u4e3a\u9a71\u52a8\u8868&#xff0c;\u6570\u636e\u67e5\u8be2\u65f6&#xff0c;\u5339\u914d\u7684\u8fc7\u7a0b\u4e2d&#xff0c;\u4f9d\u65e7\u9700\u8981\u4e0earea_test_table\u8868\u4e2d\u7684\u6bcf\u4e00\u6761\u6570\u636e\u8fdb\u884c\u5339\u914d&#xff0c;\u5339\u914d\u6548\u7387\u4f9d\u65e7\u65e0\u6cd5\u63d0\u9ad8\u3002<\/p>\n<h4 id=\"3.%20%E8%81%94%E5%90%88%E6%9F%A5%E8%AF%A2%E4%B8%AD%E7%9A%84%E6%8E%92%E5%BA%8F%E5%AD%97%E6%AE%B5%E5%AF%B9%E6%89%A7%E8%A1%8C%E8%AE%A1%E5%88%92%E7%9A%84%E5%BD%B1%E5%93%8D%E5%88%86%E6%9E%90\">3. \u8054\u5408\u67e5\u8be2\u4e2d\u7684\u6392\u5e8f\u5b57\u6bb5\u5bf9\u6267\u884c\u8ba1\u5212\u7684\u5f71\u54cd\u5206\u6790<\/h4>\n<p>\u4e0b\u9762\u662f\u6211\u4eec\u5728\u4e00\u6b21\u67e5\u8be2\u4f18\u5316\u4e2d\u9047\u5230\u7684\u4e00\u4e2a\u5178\u578b\u573a\u666f\u3002\u6211\u4eec\u5bf9\u8868 wm_ad_cpc_role_config&#xff08;\u7b80\u79f0 config&#xff09; \u548c wm_ad_cpc_role_config_open_area&#xff08;\u7b80\u79f0 area&#xff09; \u505a LEFT JOIN \u8054\u8868\u67e5\u8be2&#xff0c;\u89c2\u5bdf\u4e0d\u540c\u7684 ORDER BY \u6392\u5e8f\u5b57\u6bb5\u5bf9\u6267\u884c\u8ba1\u5212\u7684\u5f71\u54cd\u3002<\/p>\n<h5 id=\"%E6%9F%A5%E8%AF%A2%E8%AF%AD%E5%8F%A5%20A%EF%BC%88%E6%8C%89%20area.id%20%E6%8E%92%E5%BA%8F%EF%BC%89%EF%BC%9A\">\u67e5\u8be2\u8bed\u53e5 A&#xff08;\u6309 area.id \u6392\u5e8f&#xff09;&#xff1a;<\/h5>\n<p>EXPLAIN SELECT config.id, config.open_type,<br \/>\nconfig.spread_date, config.status, config.category,<br \/>\nconfig.ad_pos, config.ctime<br \/>\nFROM ad_cpc_role_config config<br \/>\nLEFT JOIN ad_cpc_role_config_open_area area<br \/>\nON area.role_config_id &#061; config.id<br \/>\nAND area.open_type &#061; config.open_type<br \/>\nORDER BY area.id; <\/p>\n<table>\n<tr>idselect_typetabletypepossible_keyskeykey_lenrefrowsfilteredExtra<\/tr>\n<tbody>\n<tr>\n<td>1<\/td>\n<td>SIMPLE<\/td>\n<td>config<\/td>\n<td>ALL<\/td>\n<td>NULL<\/td>\n<td>NULL<\/td>\n<td>NULL<\/td>\n<td>NULL<\/td>\n<td>513<\/td>\n<td>100<\/td>\n<td>Using temporary; Using filesort<\/td>\n<\/tr>\n<tr>\n<td>1<\/td>\n<td>SIMPLE<\/td>\n<td>area<\/td>\n<td>ref<\/td>\n<td>idx_role_config_id, idx_open_type, &#8230;<\/td>\n<td>idx_role_config_id<\/td>\n<td>4<\/td>\n<td>config.id<\/td>\n<td>64<\/td>\n<td>100<\/td>\n<td>Using where<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u89e3\u8bfb&#xff1a;\u7531\u4e8e\u6392\u5e8f\u5b57\u6bb5\u662f\u6765\u81ea\u88ab\u9a71\u52a8\u8868 area&#xff0c;MySQL \u65e0\u6cd5\u76f4\u63a5\u901a\u8fc7\u7d22\u5f15\u5b8c\u6210\u6392\u5e8f&#xff0c;\u56e0\u6b64\u89e6\u53d1\u4e86\u4e34\u65f6\u8868 &#043; \u6587\u4ef6\u6392\u5e8f&#xff0c;\u5373 Using temporary; Using filesort\u3002\u8fd9\u901a\u5e38\u610f\u5473\u7740\u66f4\u9ad8\u7684 CPU \u548c IO \u5f00\u9500&#xff0c;\u5c24\u5176\u662f\u5f53\u7ed3\u679c\u96c6\u8f83\u5927\u65f6\u3002<\/p>\n<h5 id=\"%E6%9F%A5%E8%AF%A2%E8%AF%AD%E5%8F%A5%20B%EF%BC%88%E6%8C%89%20config.id%20%E6%8E%92%E5%BA%8F%EF%BC%89%EF%BC%9A\">\u67e5\u8be2\u8bed\u53e5 B&#xff08;\u6309 config.id \u6392\u5e8f&#xff09;&#xff1a;<\/h5>\n<p>EXPLAIN SELECT config.id, config.open_type,<br \/>\nconfig.spread_date, config.status, config.category,<br \/>\n config.ad_pos, config.ctime<br \/>\nFROM ad_cpc_role_config config<br \/>\nLEFT JOIN ad_cpc_role_config_open_area area<br \/>\nON area.role_config_id &#061; config.id<br \/>\nAND area.open_type &#061; config.open_type ORDER BY config.id; <\/p>\n<table>\n<tr>idselect_typetabletypepossible_keyskeykey_lenrefrowsfilteredExtra<\/tr>\n<tbody>\n<tr>\n<td>1<\/td>\n<td>SIMPLE<\/td>\n<td>config<\/td>\n<td>ALL<\/td>\n<td>NULL<\/td>\n<td>NULL<\/td>\n<td>NULL<\/td>\n<td>NULL<\/td>\n<td>513<\/td>\n<td>100<\/td>\n<td>Using filesort<\/td>\n<\/tr>\n<tr>\n<td>1<\/td>\n<td>SIMPLE<\/td>\n<td>area<\/td>\n<td>ref<\/td>\n<td>idx_role_config_id, idx_open_type, &#8230;<\/td>\n<td>idx_role_config_id<\/td>\n<td>4<\/td>\n<td>config.id<\/td>\n<td>64<\/td>\n<td>100<\/td>\n<td>Using where<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u89e3\u8bfb&#xff1a;\u672c\u6b21\u6392\u5e8f\u5b57\u6bb5\u4e3a\u9a71\u52a8\u8868 config \u7684\u4e3b\u952e id&#xff0c;\u867d\u7136\u4ecd\u7136\u89e6\u53d1\u4e86 filesort&#xff08;\u56e0\u4e3a\u6ca1\u6709\u4f7f\u7528\u7d22\u5f15\u5b8c\u6210\u6392\u5e8f&#xff09;&#xff0c;\u4f46\u907f\u514d\u4e86\u4e34\u65f6\u8868\u521b\u5efa&#xff0c;\u56e0\u6b64\u76f8\u8f83\u4e8e A \u6765\u8bf4\u6027\u80fd\u66f4\u597d&#xff0c;\u8d44\u6e90\u5360\u7528\u66f4\u5c11\u3002<\/p>\n<h5 id=\"%F0%9F%8E%AF%20%E5%B0%8F%E7%BB%93\">&#x1f3af; \u5c0f\u7ed3<\/h5>\n<ul>\n<li>\n<p>\u6392\u5e8f\u5b57\u6bb5\u4f4d\u7f6e\u4e0d\u540c&#xff0c;\u4f1a\u76f4\u63a5\u5f71\u54cd\u662f\u5426\u4f7f\u7528\u4e34\u65f6\u8868\u3001\u6392\u5e8f\u7b97\u6cd5\u7684\u7c7b\u578b&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u6392\u5e8f\u5b57\u6bb5\u6765\u81ea\u88ab\u9a71\u52a8\u8868&#xff08;\u5982 area.id&#xff09;\u65f6&#xff0c;MySQL \u901a\u5e38\u65e0\u6cd5\u5229\u7528\u7d22\u5f15\u5b8c\u6210\u6392\u5e8f&#xff0c;\u5bb9\u6613\u89e6\u53d1 Using temporary; Using filesort&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u6392\u5e8f\u5b57\u6bb5\u6765\u81ea\u9a71\u52a8\u8868&#xff08;\u5982 config.id&#xff09;\u65f6&#xff0c;\u5982\u679c\u8be5\u5b57\u6bb5\u5b58\u5728\u5408\u9002\u7684\u7d22\u5f15&#xff0c;\u6216\u662f\u4e3b\u952e&#xff0c;\u4f18\u5316\u7a7a\u95f4\u66f4\u5927&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u82e5\u6392\u5e8f\u5b57\u6bb5\u662f\u5fc5\u8981\u7684&#xff0c;\u53ef\u8003\u8651\u4f7f\u7528\u8986\u76d6\u7d22\u5f15\u6216 \u63d0\u524d\u5b50\u67e5\u8be2\u6392\u5e8f\u7b49\u65b9\u5f0f\u4f18\u5316\u3002<\/p>\n<\/li>\n<\/ul>\n<h2 id=\"%E4%BA%94%E3%80%81%E6%80%BB%E7%BB%93%EF%BC%9A%E8%81%94%E5%90%88%E7%B4%A2%E5%BC%95%EF%BC%8C%E4%B8%8D%E6%AD%A2%E6%98%AF%E2%80%9C%E7%BB%84%E5%90%88%E5%AD%97%E6%AE%B5%E2%80%9D%E8%BF%99%E4%B9%88%E7%AE%80%E5%8D%95\">\u4e94\u3001\u603b\u7ed3&#xff1a;\u8054\u5408\u7d22\u5f15&#xff0c;\u4e0d\u6b62\u662f\u201c\u7ec4\u5408\u5b57\u6bb5\u201d\u8fd9\u4e48\u7b80\u5355<\/h2>\n<p>\u7ecf\u8fc7\u4e0a\u6587\u7684\u5c42\u5c42\u5256\u6790\u4e0e\u5b9e\u6218\u6f14\u7ec3&#xff0c;\u76f8\u4fe1\u4f60\u5df2\u7ecf\u610f\u8bc6\u5230&#xff1a;\u8054\u5408\u7d22\u5f15\u7edd\u4e0d\u4ec5\u4ec5\u662f\u201c\u591a\u4e2a\u5b57\u6bb5\u5408\u5728\u4e00\u8d77\u5efa\u7d22\u5f15\u201d\u8fd9\u4e48\u7b80\u5355\u3002\u5b83\u662f\u4e00\u79cd\u7cfb\u7edf\u6027\u7684\u8bbe\u8ba1\u827a\u672f&#xff0c;\u66f4\u662f\u4e00\u9879\u6570\u636e\u5e93\u8c03\u4f18\u4e2d\u7684\u201c\u786c\u6838\u6b66\u5668\u201d\u3002<\/p>\n<p>\u6211\u4eec\u4ece B&#043; \u6811\u7684\u7269\u7406\u7ed3\u6784\u8c08\u8d77&#xff0c;\u9010\u6b65\u63ed\u793a\u4e86\u8054\u5408\u7d22\u5f15\u5e95\u5c42\u662f\u5982\u4f55\u7ec4\u7ec7\u9875\u3001\u8bb0\u5f55\u3001\u6307\u9488\u7684&#xff0c;\u53c8\u662f\u5982\u4f55\u901a\u8fc7\u201c\u6700\u5de6\u524d\u7f00\u201d\u539f\u5219\u548c\u53f6\u5b50\u8282\u70b9\u7684\u6709\u5e8f\u7ed3\u6784&#xff0c;\u5b9e\u73b0\u9ad8\u6548\u7684\u6570\u636e\u5b9a\u4f4d\u4e0e\u8303\u56f4\u68c0\u7d22\u3002\u8054\u5408\u7d22\u5f15\u80fd\u6709\u6548\u9632\u6b62\u7d22\u5f15\u7b56\u7565\u5e72\u6270\u3001\u4f18\u5316\u56de\u8868\u8def\u5f84\u3001\u63d0\u5347\u8986\u76d6\u67e5\u8be2\u6548\u7387\u3001\u89e6\u53d1\u7d22\u5f15\u4e0b\u63a8\u673a\u5236&#xff0c;\u8fd9\u4e9b\u80fd\u529b\u80cc\u540e&#xff0c;\u90fd\u79bb\u4e0d\u5f00\u5b83\u4f5c\u4e3a\u201c\u6574\u4f53\u4e00\u68f5\u6811\u201d\u7684\u7ed3\u6784\u8bbe\u8ba1\u3002<\/p>\n<p>\u66f4\u91cd\u8981\u7684\u662f&#xff0c;\u6211\u4eec\u901a\u8fc7\u4e00\u7cfb\u5217\u8d34\u8fd1\u5b9e\u6218\u7684\u6848\u4f8b&#xff0c;\u770b\u5230\u4e86\u8054\u5408\u7d22\u5f15\u5728\u771f\u5b9e\u4e1a\u52a1\u4e2d\u662f\u5982\u4f55\u201c\u663e\u795e\u901a\u201d\u7684&#xff1a;\u4ece\u5e7f\u544a\u7cfb\u7edf\u7684\u9ad8\u9891\u68c0\u7d22&#xff0c;\u5230\u590d\u6742\u591a\u53d8\u7684\u6392\u5e8f\u4f18\u5316\u7b56\u7565&#xff0c;\u518d\u5230\u5bf9\u6162\u67e5\u8be2\u7684\u7cbe\u51c6\u201c\u6253\u51fb\u201d&#xff0c;\u6bcf\u4e00\u6b21\u63d0\u5347\u90fd\u51dd\u7ed3\u7740\u7d22\u5f15\u8bbe\u8ba1\u7684\u667a\u6167\u4e0e\u7ecf\u9a8c\u7684\u6c89\u6dc0\u3002<\/p>\n<p>\u53ef\u4ee5\u8bf4&#xff0c;\u8054\u5408\u7d22\u5f15\u662f\u8fde\u63a5\u6570\u636e\u5e93\u201c\u7406\u8bba\u4e16\u754c\u201d\u4e0e\u201c\u5b9e\u9645\u67e5\u8be2\u201d\u7684\u6865\u6881&#xff0c;\u65e2\u9700\u8981\u4f60\u5bf9 MySQL \u6267\u884c\u8ba1\u5212\u6709\u8db3\u591f\u7684\u654f\u611f\u5ea6&#xff0c;\u4e5f\u9700\u8981\u4f60\u5bf9\u4e1a\u52a1\u6570\u636e\u5206\u5e03\u4e86\u5982\u6307\u638c\u3002\u53ea\u6709\u7406\u89e3\u5b83\u3001\u638c\u63e1\u5b83\u3001\u5ba1\u614e\u4f7f\u7528\u5b83&#xff0c;\u8054\u5408\u7d22\u5f15\u624d\u80fd\u771f\u6b63\u6210\u4e3a\u4f60\u624b\u4e2d\u7a33\u5b9a\u3001\u81f4\u547d\u7684\u4e00\u5f20\u201c\u6027\u80fd\u738b\u724c\u201d\u3002<\/p>\n<p>&#x1f3af; \u6700\u540e\u9001\u4f60\u4e00\u53e5\u8bdd\u4f5c\u7ed3&#xff1a;<\/p>\n<p>\u5982\u679c\u8bf4\u5355\u5217\u7d22\u5f15\u662f\u201c\u5355\u6253\u72ec\u6597\u201d\u7684\u58eb\u5175&#xff0c;\u90a3\u4e48\u8054\u5408\u7d22\u5f15\u5c31\u662f\u201c\u534f\u540c\u4f5c\u6218\u201d\u7684\u7279\u79cd\u90e8\u961f \u2014\u2014 \u5728\u5bf9\u7684\u6218\u573a&#xff0c;\u5b83\u603b\u80fd\u4e00\u51fb\u5fc5\u4e2d\u3002<\/p>\n<\/p>\n<\/p>\n<\/p>\n<\/p>\n<\/p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.1w\u6b21\uff0c\u70b9\u8d5e123\u6b21\uff0c\u6536\u85cf61\u6b21\u3002\u8054\u5408\u7d22\u5f15\u5e76\u975e\u7b80\u5355\u7684\u5b57\u6bb5\u62fc\u63a5\uff0c\u800c\u662f MySQL \u4e2d\u5f3a\u5927\u4e14\u9ad8\u6548\u7684\u67e5\u8be2\u5229\u5668\u3002\u672c\u6587\u4ece B+ \u6811\u7ed3\u6784\u8bb2\u8d77\uff0c\u6df1\u5165\u5256\u6790\u8054\u5408\u7d22\u5f15\u7684\u7ec4\u7ec7\u65b9\u5f0f\u3001\u6700\u5de6\u524d\u7f00\u539f\u5219\u53ca\u5176\u5728\u6267\u884c\u8ba1\u5212\u4e2d\u7684\u4f18\u5316\u6548\u679c\u3002\u7ed3\u5408\u771f\u5b9e\u6848\u4f8b\uff0c\u5c55\u793a\u5b83\u5982\u4f55\u63d0\u5347\u67e5\u8be2\u6548\u7387\u3001\u51cf\u5c11\u56de\u8868\u3001\u652f\u6301\u8986\u76d6\u67e5\u8be2\u4e0e\u7d22\u5f15\u4e0b\u63a8\u3002\u6587\u7ae0\u8fd8\u6307\u51fa\u5e38\u89c1\u8bbe\u8ba1\u8bef\u533a\uff0c\u5e2e\u52a9\u8bfb\u8005\u6784\u5efa\u7cfb\u7edf\u7684\u7d22\u5f15\u4f18\u5316\u601d\u7ef4\u3002\u638c\u63e1\u8054\u5408\u7d22\u5f15\uff0c\u8ba9\u4f60\u5728\u9762\u5bf9\u590d\u6742\u67e5\u8be2\u65f6\u66f4\u4ece\u5bb9\u3002_mysql\u8054\u5408\u7d22\u5f15\u7ed3\u6784<\/p>\n","protected":false},"author":2,"featured_media":51130,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[114,5043,100],"topic":[],"class_list":{"0":"post-51150","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","6":"hentry","7":"category-server","8":"tag-mysql","10":"tag-100"},"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u8054\u5408\u7d22\u5f15\u5168\u89e3\u6790\uff1a\u4e00\u68f5\u6811\uff0c\u6491\u8d77\u67e5\u8be2\u7684\u534a\u8fb9\u5929 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/51150.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u8054\u5408\u7d22\u5f15\u5168\u89e3\u6790\uff1a\u4e00\u68f5\u6811\uff0c\u6491\u8d77\u67e5\u8be2\u7684\u534a\u8fb9\u5929 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.1w\u6b21\uff0c\u70b9\u8d5e123\u6b21\uff0c\u6536\u85cf61\u6b21\u3002\u8054\u5408\u7d22\u5f15\u5e76\u975e\u7b80\u5355\u7684\u5b57\u6bb5\u62fc\u63a5\uff0c\u800c\u662f MySQL \u4e2d\u5f3a\u5927\u4e14\u9ad8\u6548\u7684\u67e5\u8be2\u5229\u5668\u3002\u672c\u6587\u4ece B+ \u6811\u7ed3\u6784\u8bb2\u8d77\uff0c\u6df1\u5165\u5256\u6790\u8054\u5408\u7d22\u5f15\u7684\u7ec4\u7ec7\u65b9\u5f0f\u3001\u6700\u5de6\u524d\u7f00\u539f\u5219\u53ca\u5176\u5728\u6267\u884c\u8ba1\u5212\u4e2d\u7684\u4f18\u5316\u6548\u679c\u3002\u7ed3\u5408\u771f\u5b9e\u6848\u4f8b\uff0c\u5c55\u793a\u5b83\u5982\u4f55\u63d0\u5347\u67e5\u8be2\u6548\u7387\u3001\u51cf\u5c11\u56de\u8868\u3001\u652f\u6301\u8986\u76d6\u67e5\u8be2\u4e0e\u7d22\u5f15\u4e0b\u63a8\u3002\u6587\u7ae0\u8fd8\u6307\u51fa\u5e38\u89c1\u8bbe\u8ba1\u8bef\u533a\uff0c\u5e2e\u52a9\u8bfb\u8005\u6784\u5efa\u7cfb\u7edf\u7684\u7d22\u5f15\u4f18\u5316\u601d\u7ef4\u3002\u638c\u63e1\u8054\u5408\u7d22\u5f15\uff0c\u8ba9\u4f60\u5728\u9762\u5bf9\u590d\u6742\u67e5\u8be2\u65f6\u66f4\u4ece\u5bb9\u3002_mysql\u8054\u5408\u7d22\u5f15\u7ed3\u6784\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/51150.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-08-10T10:14:58+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250810101440-68987110eafe6.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"23 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/51150.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/51150.html\",\"name\":\"\u8054\u5408\u7d22\u5f15\u5168\u89e3\u6790\uff1a\u4e00\u68f5\u6811\uff0c\u6491\u8d77\u67e5\u8be2\u7684\u534a\u8fb9\u5929 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-08-10T10:14:58+00:00\",\"dateModified\":\"2025-08-10T10:14:58+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/51150.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/51150.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/51150.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u8054\u5408\u7d22\u5f15\u5168\u89e3\u6790\uff1a\u4e00\u68f5\u6811\uff0c\u6491\u8d77\u67e5\u8be2\u7684\u534a\u8fb9\u5929\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u8054\u5408\u7d22\u5f15\u5168\u89e3\u6790\uff1a\u4e00\u68f5\u6811\uff0c\u6491\u8d77\u67e5\u8be2\u7684\u534a\u8fb9\u5929 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/51150.html","og_locale":"zh_CN","og_type":"article","og_title":"\u8054\u5408\u7d22\u5f15\u5168\u89e3\u6790\uff1a\u4e00\u68f5\u6811\uff0c\u6491\u8d77\u67e5\u8be2\u7684\u534a\u8fb9\u5929 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.1w\u6b21\uff0c\u70b9\u8d5e123\u6b21\uff0c\u6536\u85cf61\u6b21\u3002\u8054\u5408\u7d22\u5f15\u5e76\u975e\u7b80\u5355\u7684\u5b57\u6bb5\u62fc\u63a5\uff0c\u800c\u662f MySQL \u4e2d\u5f3a\u5927\u4e14\u9ad8\u6548\u7684\u67e5\u8be2\u5229\u5668\u3002\u672c\u6587\u4ece B+ \u6811\u7ed3\u6784\u8bb2\u8d77\uff0c\u6df1\u5165\u5256\u6790\u8054\u5408\u7d22\u5f15\u7684\u7ec4\u7ec7\u65b9\u5f0f\u3001\u6700\u5de6\u524d\u7f00\u539f\u5219\u53ca\u5176\u5728\u6267\u884c\u8ba1\u5212\u4e2d\u7684\u4f18\u5316\u6548\u679c\u3002\u7ed3\u5408\u771f\u5b9e\u6848\u4f8b\uff0c\u5c55\u793a\u5b83\u5982\u4f55\u63d0\u5347\u67e5\u8be2\u6548\u7387\u3001\u51cf\u5c11\u56de\u8868\u3001\u652f\u6301\u8986\u76d6\u67e5\u8be2\u4e0e\u7d22\u5f15\u4e0b\u63a8\u3002\u6587\u7ae0\u8fd8\u6307\u51fa\u5e38\u89c1\u8bbe\u8ba1\u8bef\u533a\uff0c\u5e2e\u52a9\u8bfb\u8005\u6784\u5efa\u7cfb\u7edf\u7684\u7d22\u5f15\u4f18\u5316\u601d\u7ef4\u3002\u638c\u63e1\u8054\u5408\u7d22\u5f15\uff0c\u8ba9\u4f60\u5728\u9762\u5bf9\u590d\u6742\u67e5\u8be2\u65f6\u66f4\u4ece\u5bb9\u3002_mysql\u8054\u5408\u7d22\u5f15\u7ed3\u6784","og_url":"https:\/\/www.wsisp.com\/helps\/51150.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-08-10T10:14:58+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250810101440-68987110eafe6.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"23 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/51150.html","url":"https:\/\/www.wsisp.com\/helps\/51150.html","name":"\u8054\u5408\u7d22\u5f15\u5168\u89e3\u6790\uff1a\u4e00\u68f5\u6811\uff0c\u6491\u8d77\u67e5\u8be2\u7684\u534a\u8fb9\u5929 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-08-10T10:14:58+00:00","dateModified":"2025-08-10T10:14:58+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/51150.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/51150.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/51150.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u8054\u5408\u7d22\u5f15\u5168\u89e3\u6790\uff1a\u4e00\u68f5\u6811\uff0c\u6491\u8d77\u67e5\u8be2\u7684\u534a\u8fb9\u5929"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/51150","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=51150"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/51150\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/51130"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=51150"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=51150"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=51150"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=51150"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}