{"id":2072,"date":"2024-05-25T11:03:02","date_gmt":"2024-05-25T03:03:02","guid":{"rendered":"http:\/\/oneai.eu.org\/?p=2072"},"modified":"2024-05-25T11:03:02","modified_gmt":"2024-05-25T03:03:02","slug":"%e8%be%be%e6%a2%a6-%e6%9f%a5%e8%af%a2%e4%bc%98%e5%8c%96","status":"publish","type":"post","link":"https:\/\/oneai.eu.org\/?p=2072","title":{"rendered":"\u8fbe\u68a6-\u67e5\u8be2\u4f18\u5316"},"content":{"rendered":"<div>\n<p>\u6570\u636e\u5e93\u6267\u884c\u4e00\u6761\u8bed\u53e5\u6709\u591a\u79cd\u65b9\u5f0f\uff0c\u4e3a\u4e86\u9009\u62e9\u6700\u4f18\u7684\u6267\u884c\u65b9\u5f0f\uff0c\u4ea7\u751f\u4e86\u67e5\u8be2\u4f18\u5316\u5668\u3002\u67e5\u8be2\u4f18\u5316\u5668\u5206\u6790\u8bed\u53e5\u8fd0\u884c\u65f6\u7684\u6240\u6709\u56e0\u7d20\uff0c\u9009\u62e9\u6700\u4f18\u7684\u65b9\u5f0f\u53bb\u6267\u884c\uff0c\u63d0\u9ad8\u4e86\u67e5\u8be2\u6548\u7387\u3002\u56e0\u6b64\uff0c\u67e5\u8be2\u4f18\u5316\u662f\u6570\u636e\u5e93\u6267\u884c SQL \u8bed\u53e5\u7684\u91cd\u8981\u8fc7\u7a0b\uff0c\u51b3\u5b9a\u4e86\u6570\u636e\u5e93\u7684\u67e5\u8be2\u6027\u80fd\u3002<\/p>\n<h2 id=\"22-1-\u4f18\u5316\u76ee\u6807\" class=\"article-heading\" style=\"position: relative;\">22.1 \u4f18\u5316\u76ee\u6807<a class=\"article-anchor\" href=\"#22.1 \u4f18\u5316\u76ee\u6807\" aria-hidden=\"true\"><\/a><\/p>\n<div id=\"22.1 \u4f18\u5316\u76ee\u6807\" style=\"position: absolute; top: -100px;\"><\/div>\n<\/h2>\n<p>\u8fbe\u68a6\u6570\u636e\u5e93\u67e5\u8be2\u4f18\u5316\u5668\u7684\u4f18\u5316\u76ee\u6807\u4e3a\u6700\u5feb\u54cd\u5e94\u65f6\u95f4\u3002\u901a\u8fc7\u8bbe\u7f6e\u53c2\u6570 FIRST_ROWS \u6765\u51b3\u5b9a\u4f18\u5148\u8fd4\u56de\u591a\u5c11\u6761\u8bb0\u5f55\u7ed9\u7528\u6237\uff0c\u800c\u4e0d\u9700\u8981\u7b49\u5f85\u5168\u90e8\u7ed3\u679c\u786e\u5b9a\u540e\u518d\u8f93\u51fa\uff0cFIRST_ROWS \u8bbe\u7f6e\u8303\u56f4\u4e3a 1~1000\uff0c\u5355\u4f4d\u4e3a\u884c\u3002\u4f8b\u5982\uff1aFIRST_ROWS = 10\uff0c\u610f\u601d\u662f\u67e5\u8be2\u51fa 10 \u6761\u7ed3\u679c\u5c31\u7acb\u5373\u8fd4\u56de\u7ed9\u7528\u6237\u3002\u53ef\u4ee5\u6839\u636e\u5b9e\u9645\u60c5\u51b5\uff0c\u8c03\u6574\u53c2\u6570\u503c\u3002<\/p>\n<h2 id=\"22-2-\u67e5\u8be2\u4f18\u5316\u5668\" class=\"article-heading\" style=\"position: relative;\">22.2 \u67e5\u8be2\u4f18\u5316\u5668<a class=\"article-anchor\" href=\"#22.2 \u67e5\u8be2\u4f18\u5316\u5668\" aria-hidden=\"true\"><\/a><\/p>\n<div id=\"22.2 \u67e5\u8be2\u4f18\u5316\u5668\" style=\"position: absolute; top: -100px;\"><\/div>\n<\/h2>\n<p>\u67e5\u8be2\u4f18\u5316\u5668\u901a\u8fc7\u5206\u6790\u53ef\u7528\u7684\u6267\u884c\u65b9\u5f0f\u548c\u67e5\u8be2\u6240\u6d89\u53ca\u7684\u5bf9\u8c61\u7edf\u8ba1\u4fe1\u606f\u6765\u751f\u6210\u6700\u4f18\u7684\u6267\u884c\u8ba1\u5212\u3002\u6b64\u5916\uff0c\u5982\u679c\u5b58\u5728 HINT \u4f18\u5316\u63d0\u793a\uff0c\u4f18\u5316\u5668\u8fd8\u9700\u8981\u8003\u8651\u4f18\u5316\u63d0\u793a\u7684\u56e0\u7d20\u3002<\/p>\n<p>\u67e5\u8be2\u4f18\u5316\u5668\u7684\u5904\u7406\u8fc7\u7a0b\u5305\u62ec\uff1a<\/p>\n<ol>\n<li>\u4f18\u5316\u5668\u751f\u6210\u6240\u6709\u53ef\u80fd\u7684\u6267\u884c\u8ba1\u5212\u96c6\u5408\uff1b<\/li>\n<li>\u4f18\u5316\u5668\u57fa\u4e8e\u5b57\u5178\u4fe1\u606f\u7684\u6570\u636e\u5206\u5e03\u7edf\u8ba1\u503c\u3001\u6267\u884c\u8bed\u53e5\u6d89\u53ca\u5230\u7684\u8868\u3001\u7d22\u5f15\u548c\u5206\u533a\u7684\u5b58\u50a8\u7279\u70b9\u6765\u4f30\u7b97\u6bcf\u4e2a\u6267\u884c\u8ba1\u5212\u7684\u4ee3\u4ef7\u3002\u4ee3\u4ef7\u662f\u6307 SQL \u8bed\u53e5\u4f7f\u7528\u67d0\u79cd\u6267\u884c\u65b9\u5f0f\u6240\u6d88\u8017\u7684\u7cfb\u7edf\u8d44\u6e90\u7684\u4f30\u7b97\u503c\u3002\u5176\u4e2d\uff0c\u7cfb\u7edf\u8d44\u6e90\u6d88\u8017\u5305\u62ec I\/O\u3001CPU \u4f7f\u7528\u60c5\u51b5\u3001\u5185\u5b58\u6d88\u8017\u7b49\uff1b<\/li>\n<li>\u4f18\u5316\u5668\u9009\u62e9\u4ee3\u4ef7\u6700\u5c0f\u7684\u6267\u884c\u65b9\u5f0f\u4f5c\u4e3a\u8be5\u6761\u8bed\u53e5\u7684\u6700\u7ec8\u6267\u884c\u8ba1\u5212\u3002<\/li>\n<\/ol>\n<p>\u4f18\u5316\u5668\u6240\u505a\u7684\u64cd\u4f5c\u6709\uff1a\u67e5\u8be2\u8f6c\u6362\u3001\u4f30\u7b97\u4ee3\u4ef7\u3001\u751f\u6210\u8ba1\u5212\u3002<\/p>\n<h3 id=\"22-2-1-\u67e5\u8be2\u8f6c\u6362\" class=\"article-heading\" style=\"position: relative;\">22.2.1 \u67e5\u8be2\u8f6c\u6362<a class=\"article-anchor\" href=\"#22.2.1 \u67e5\u8be2\u8f6c\u6362\" aria-hidden=\"true\"><\/a><\/p>\n<div id=\"22.2.1 \u67e5\u8be2\u8f6c\u6362\" style=\"position: absolute; top: -100px;\"><\/div>\n<\/h3>\n<p>\u67e5\u8be2\u8f6c\u6362\u662f\u6307\u628a\u7ecf\u8fc7\u8bed\u6cd5\u3001\u8bed\u4e49\u5206\u6790\u7684\u67e5\u8be2\u5757\u4e4b\u95f4\u7684\u8fde\u63a5\u7c7b\u578b\u3001\u5d4c\u5957\u5173\u7cfb\u8fdb\u884c\u8c03\u6574\uff0c\u751f\u6210\u4e00\u4e2a\u66f4\u597d\u7684\u67e5\u8be2\u8ba1\u5212\u3002\u5e38\u7528\u7684\u67e5\u8be2\u8f6c\u6362\u6280\u672f\u5305\u62ec\u8fc7\u6ee4\u6761\u4ef6\u7684\u4e0b\u653e\u3001\u76f8\u5173\u5b50\u67e5\u8be2\u7684\u53bb\u76f8\u5173\u6027\u3002<\/p>\n<ol>\n<li>\u8fc7\u6ee4\u6761\u4ef6\u4e0b\u653e\uff1a\u5728\u8fde\u63a5\u67e5\u8be2\u4e2d\uff0c\u628a\u90e8\u5206\u8868\u7684\u8fc7\u6ee4\u6761\u4ef6\u4e0b\u79fb\uff0c\u5728\u8fde\u63a5\u4e4b\u524d\u5148\u8fc7\u6ee4\uff0c\u53ef\u4ee5\u51cf\u5c11\u8fde\u63a5\u64cd\u4f5c\u7684\u6570\u636e\u91cf\uff0c\u63d0\u5347\u8bed\u53e5\u6027\u80fd\uff1b<\/li>\n<li>\u76f8\u5173\u5b50\u67e5\u8be2\u7684\u53bb\u76f8\u5173\u6027\uff1a\u628a\u4e0e\u5b50\u67e5\u8be2\u76f8\u5173\u7684\u5916\u8868\u4e0e\u5185\u8868\u91c7\u7528\u534a\u8fde\u63a5\u7684\u65b9\u5f0f\u6267\u884c\uff0c\u653e\u5f03\u9ed8\u8ba4\u91c7\u53d6\u7684\u5d4c\u5957\u8fde\u63a5\u65b9\u5f0f\uff0c\u5bf9\u6027\u80fd\u6709\u8f83\u5927\u63d0\u5347\u3002<\/li>\n<\/ol>\n<h3 id=\"22-2-2-\u4f30\u7b97\u4ee3\u4ef7\" class=\"article-heading\" style=\"position: relative;\">22.2.2 \u4f30\u7b97\u4ee3\u4ef7<a class=\"article-anchor\" href=\"#22.2.2 \u4f30\u7b97\u4ee3\u4ef7\" aria-hidden=\"true\"><\/a><\/p>\n<div id=\"22.2.2 \u4f30\u7b97\u4ee3\u4ef7\" style=\"position: absolute; top: -100px;\"><\/div>\n<\/h3>\n<p>\u4f30\u7b97\u4ee3\u4ef7\u662f\u6307\u5bf9\u6267\u884c\u8ba1\u5212\u7684\u6210\u672c\u8fdb\u884c\u4f30\u7b97\u3002\u6267\u884c\u8282\u70b9\u4e4b\u95f4\u7684\u4ee3\u4ef7\u503c\u76f8\u5173\u6027\u8f83\u5f3a\uff0c\u4e00\u4e2a\u6267\u884c\u8282\u70b9\u7684\u4ee3\u4ef7\u5305\u62ec\u8be5\u8282\u70b9\u5305\u542b\u7684\u5b50\u8282\u70b9\u4ee3\u4ef7\u3002\u4ee3\u4ef7\u8861\u91cf\u6307\u6807\u5305\u62ec\u9009\u62e9\u7387\u3001\u57fa\u6570\u3001\u4ee3\u4ef7\u3002<\/p>\n<p>\u9009\u62e9\u7387\u662f\u6307\u6ee1\u8db3\u6761\u4ef6\u7684\u8bb0\u5f55\u5360\u603b\u8bb0\u5f55\u6570\u7684\u767e\u5206\u6bd4\u3002\u8bb0\u5f55\u96c6\u53ef\u4ee5\u662f\u57fa\u8868\u3001\u89c6\u56fe\u3001\u8fde\u63a5\u6216\u5206\u7ec4\u64cd\u4f5c\u7684\u7ed3\u679c\u96c6\u3002\u9009\u62e9\u7387\u548c\u67e5\u8be2\u8c13\u8bcd\u76f8\u5173\uff0c\u5982 name = \u2018\u97e9\u6885\u6885\u2019\uff1b\u6216\u8005\u662f\u8c13\u8bcd\u7684\u8fde\u63a5\uff0c\u5982 name =\u2018\u97e9\u6885\u6885\u2019 and no =\u20180123\u2019\u3002\u4e00\u4e2a\u8c13\u8bcd\u53ef\u4ee5\u770b\u4f5c\u662f\u4e00\u4e2a\u8fc7\u6ee4\u5668\uff0c\u8fc7\u6ee4\u6389\u7ed3\u679c\u96c6\u4e2d\u4e0d\u6ee1\u8db3\u6761\u4ef6\u7684\u8bb0\u5f55\u3002\u9009\u62e9\u7387\u7684\u8303\u56f4\u4ece 0 \u5230 1\u3002\u5176\u4e2d\uff0c0 \u8868\u793a\u6ca1\u6709\u8bb0\u5f55\u88ab\u9009\u4e2d\uff0c1 \u8868\u793a\u884c\u96c6\u4e2d\u6240\u6709\u8bb0\u5f55\u90fd\u88ab\u9009\u4e2d\u3002<\/p>\n<p>\u5982\u679c\u6ca1\u6709\u7edf\u8ba1\u4fe1\u606f\uff0c\u5219\u4f18\u5316\u5668\u4f9d\u636e\u8fc7\u6ee4\u6761\u4ef6\u7684\u7c7b\u578b\u6765\u8bbe\u7f6e\u5bf9\u5e94\u7684\u9009\u62e9\u7387\u3002\u4f8b\u5982\uff0c\u7b49\u503c\u6761\u4ef6\u7684\u9009\u62e9\u7387\u4f4e\u4e8e\u8303\u56f4\u6761\u4ef6\u9009\u62e9\u7387\u3002\u8fd9\u4e9b\u5047\u5b9a\u662f\u6839\u636e\u7ecf\u9a8c\u503c\uff0c\u8ba4\u4e3a\u7b49\u503c\u6761\u4ef6\u8fd4\u56de\u7684\u7ed3\u679c\u96c6\u6700\u5c11\u3002<\/p>\n<p>\u5982\u679c\u6709\u7edf\u8ba1\u4fe1\u606f\uff0c\u5219\u53ef\u4ee5\u4f7f\u7528\u7edf\u8ba1\u4fe1\u606f\u6765\u4f30\u7b97\u9009\u62e9\u7387\u3002\u4f8b\u5982\uff0c\u5bf9\u4e8e\u7b49\u503c\u8c13\u8bcd\uff08name =\u2018\u97e9\u6885\u6885\u2019\uff09\uff0c\u5982\u679c name \u5217\u6709 N \u4e2a\u4e0d\u540c\u503c\uff0c\u90a3\u4e48\uff0c\u9009\u62e9\u7387\u662f N \u5206\u4e4b\u4e00\u3002<\/p>\n<p>\u57fa\u6570\u662f\u6307\u6574\u4e2a\u884c\u96c6\u7684\u884c\u6570\uff0c\u8be5\u884c\u96c6\u53ef\u4ee5\u662f\u57fa\u8868\u3001\u89c6\u56fe\u3001\u8fde\u63a5\u6216\u5206\u7ec4\u64cd\u4f5c\u7684\u7ed3\u679c\u96c6\u3002<\/p>\n<p>\u4ee3\u4ef7\u8868\u793a\u8d44\u6e90\u7684\u4f7f\u7528\u60c5\u51b5\u3002\u67e5\u8be2\u4f18\u5316\u5668\u4f7f\u7528\u78c1\u76d8 I\/O\u3001CPU \u5360\u7528\u548c\u5185\u5b58\u4f7f\u7528\u4f5c\u4e3a\u4ee3\u4ef7\u8ba1\u7b97\u7684\u4f9d\u636e\uff0c\u6240\u4ee5\u4ee3\u4ef7\u53ef\u4ee5\u7528 I\/O \u6570\u3001CPU \u4f7f\u7528\u7387\u548c\u5185\u5b58\u4f7f\u7528\u4e00\u7ec4\u503c\u6765\u8868\u793a\u3002\u6240\u6709\u64cd\u4f5c\u90fd\u53ef\u4ee5\u8fdb\u884c\u4ee3\u4ef7\u8ba1\u7b97\uff0c\u4f8b\u5982\u626b\u63cf\u57fa\u8868\u3001\u7d22\u5f15\u626b\u63cf\u3001\u8fde\u63a5\u64cd\u4f5c\u6216\u8005\u5bf9\u7ed3\u679c\u96c6\u6392\u5e8f\u7b49\u3002<\/p>\n<p>\u8bbf\u95ee\u8def\u5f84\u51b3\u5b9a\u4e86\u4ece\u4e00\u4e2a\u57fa\u8868\u4e2d\u83b7\u53d6\u6570\u636e\u6240\u9700\u8981\u7684\u4ee3\u4ef7\u3002\u8bbf\u95ee\u8def\u5f84\u53ef\u4ee5\u662f\u57fa\u8868\u626b\u63cf\u3001\u7d22\u5f15\u626b\u63cf\u7b49\u3002\u5728\u8fdb\u884c\u57fa\u8868\u626b\u63cf\u6216\u7d22\u5f15\u626b\u63cf\u65f6\uff0c\u4e00\u6b21 I\/O \u8bfb\u591a\u4e2a\u9875\uff0c\u6240\u4ee5\uff0c\u57fa\u8868\u626b\u63cf\u6216\u7d22\u5f15\u5168\u626b\u63cf\u7684\u4ee3\u4ef7\u4f9d\u8d56\u4e8e\u8868\u7684\u6570\u636e\u9875\u6570\u548c\u591a\u9875\u8bfb\u7684\u53c2\u6570\u503c\u3002\u4e8c\u7ea7\u7d22\u5f15\u626b\u63cf\u7684\u4ee3\u4ef7\u4f9d\u8d56\u4e8e B \u6811\u7684\u5c42\u6b21\u3001\u9700\u626b\u63cf\u7684\u53f6\u5b50\u5757\u6811\u4ee5\u53ca\u6839\u636e rowid \u8bbf\u95ee\u805a\u96c6\u7d22\u5f15\u7684\u8bb0\u5f55\u6570\u3002<\/p>\n<p>\u8fde\u63a5\u4ee3\u4ef7\u662f\u6307\u8bbf\u95ee\u4e24\u4e2a\u8fde\u63a5\u7684\u7ed3\u679c\u96c6\u4ee3\u4ef7\u4e0e\u8fde\u63a5\u64cd\u4f5c\u7684\u4ee3\u4ef7\u4e4b\u548c\u3002<\/p>\n<h3 id=\"22-2-3-\u751f\u6210\u8ba1\u5212\" class=\"article-heading\" style=\"position: relative;\">22.2.3 \u751f\u6210\u8ba1\u5212<a class=\"article-anchor\" href=\"#22.2.3 \u751f\u6210\u8ba1\u5212\" aria-hidden=\"true\"><\/a><\/p>\n<div id=\"22.2.3 \u751f\u6210\u8ba1\u5212\" style=\"position: absolute; top: -100px;\"><\/div>\n<\/h3>\n<p>\u751f\u6210\u8ba1\u5212\u6307\u8ba1\u5212\u751f\u6210\u5668\u5bf9\u7ed9\u5b9a\u7684\u67e5\u8be2\u6309\u7167\u8fde\u63a5\u65b9\u5f0f\u3001\u8fde\u63a5\u987a\u5e8f\u3001\u8bbf\u95ee\u8def\u5f84\u751f\u6210\u4e0d\u540c\u7684\u6267\u884c\u8ba1\u5212\uff0c\u9009\u62e9\u4ee3\u4ef7\u6700\u5c0f\u7684\u4e00\u4e2a\u4f5c\u4e3a\u6700\u7ec8\u7684\u6267\u884c\u8ba1\u5212\u3002<\/p>\n<p>\u8fde\u63a5\u987a\u5e8f\u6307\u4e0d\u540c\u8fde\u63a5\u9879\u7684\u5904\u7406\u987a\u5e8f\u3002\u8fde\u63a5\u9879\u53ef\u4ee5\u662f\u57fa\u8868\u3001\u89c6\u56fe\u3001\u6216\u8005\u662f\u4e00\u4e2a\u4e2d\u95f4\u7ed3\u679c\u96c6\u3002\u4f8b\u5982\u8868 t1\u3001t2\u3001t3 \u7684\u8fde\u63a5\u987a\u5e8f\u662f\u5148\u8bbf\u95ee t1\uff0c\u518d\u8bbf\u95ee t2\uff0c\u7136\u540e\u5bf9 t1 \u4e0e t2 \u505a\u8fde\u63a5\u751f\u6210\u7ed3\u679c\u96c6 r1\uff0c\u6700\u540e\u628a t3 \u4e0e r1 \u505a\u8fde\u63a5\u3002\u4e00\u4e2a\u67e5\u8be2\u8bed\u53e5\u53ef\u80fd\u7684\u8ba1\u5212\u6570\u91cf\u662f\u4e0e FROM \u8bed\u53e5\u4e2d\u8fde\u63a5\u9879\u7684\u6570\u91cf\u6210\u6b63\u6bd4\u7684\uff0c\u968f\u7740\u8fde\u63a5\u9879\u7684\u6570\u91cf\u589e\u52a0\u800c\u589e\u52a0\u3002<\/p>\n<h2 id=\"22-3-\u6570\u636e\u8bbf\u95ee\u8def\u5f84\" class=\"article-heading\" style=\"position: relative;\">22.3 \u6570\u636e\u8bbf\u95ee\u8def\u5f84<a class=\"article-anchor\" href=\"#22.3 \u6570\u636e\u8bbf\u95ee\u8def\u5f84\" aria-hidden=\"true\"><\/a><\/p>\n<div id=\"22.3 \u6570\u636e\u8bbf\u95ee\u8def\u5f84\" style=\"position: absolute; top: -100px;\"><\/div>\n<\/h2>\n<p>\u8bbf\u95ee\u8def\u5f84\u6307\u4ece\u6570\u636e\u5e93\u4e2d\u68c0\u7d22\u6570\u636e\u7684\u65b9\u6cd5\u3002\u4e00\u822c\u60c5\u51b5\u4e0b\uff0c\u7d22\u5f15\u8bbf\u95ee\u7528\u4e8e\u68c0\u7d22\u8868\u7684\u5c0f\u90e8\u5206\u6570\u636e\uff0c\u5168\u8868\u626b\u63cf\u7528\u4e8e\u8bbf\u95ee\u8868\u7684\u5927\u90e8\u5206\u6570\u636e\u3002OLTP \u5e94\u7528\u4e2d\uff0c\u4e00\u822c\u4f7f\u7528\u7d22\u5f15\u8bbf\u95ee\u8def\u5f84\uff0c\u56e0\u4e3a OLTP \u4e2d\u5305\u542b\u4e86\u8bb8\u591a\u9ad8\u9009\u62e9\u7387\u7684 SQL \u8bed\u53e5\u3002\u800c\u51b3\u7b56\u652f\u6301\u7cfb\u7edf\u5219\u503e\u5411\u4e8e\u6267\u884c\u5168\u8868\u626b\u63cf\u6765\u83b7\u53d6\u6570\u636e\u3002\u4ece\u6570\u636e\u5e93\u4e2d\u5b9a\u4f4d\u548c\u68c0\u7d22\u6570\u636e\u7684\u65b9\u6cd5\u6709\uff1a\u5168\u8868\u626b\u63cf\u3001\u805a\u96c6\u7d22\u5f15\u626b\u63cf\u3001\u4e8c\u7ea7\u7d22\u5f15\u626b\u63cf\u7b49\u3002<\/p>\n<p>\u5168\u8868\u626b\u63cf\u662f\u6307\u4ece\u57fa\u8868\u4e2d\u68c0\u7d22\u6570\u636e\u65f6\uff0c\u626b\u63cf\u8be5\u8868\u4e2d\u6240\u6709\u7684\u6570\u636e\u3002\u5168\u8868\u626b\u63cf\u65b9\u5f0f\u9002\u5408\u68c0\u7d22\u8868\u4e2d\u5927\u90e8\u5206\u6570\u636e\uff0c\u8fd9\u65f6\u6bd4\u7d22\u5f15\u626b\u63cf\u66f4\u52a0\u6709\u6548\u7387\u3002<\/p>\n<p>\u7d22\u5f15\u626b\u63cf\u662f\u6307\u901a\u8fc7\u6307\u5b9a\u8bed\u53e5\u4e2d\u7684\u7d22\u5f15\u5217\u8fdb\u884c\u904d\u5386\u6765\u68c0\u7d22\u8868\u4e2d\u7684\u6570\u636e\u3002\u7d22\u5f15\u626b\u63cf\u662f\u4ece\u57fa\u4e8e\u4e00\u5217\u6216\u591a\u5217\u7684\u7d22\u5f15\u4e2d\u68c0\u7d22\u6570\u636e\u3002\u7d22\u5f15\u4e0d\u4ec5\u5305\u542b\u7d22\u5f15\u503c\uff0c\u8fd8\u5305\u542b\u5bf9\u5e94\u8868\u4e2d\u6570\u636e\u7684 ROWID\u3002\u5982\u679c\u9700\u8981\u8bbf\u95ee\u7684\u4e0d\u662f\u7d22\u5f15\u5217\uff0c\u8fd9\u65f6\u9700\u8981\u901a\u8fc7 ROWID \u6216\u805a\u96c6\u7d22\u5f15\u6765\u627e\u5230\u8868\u4e2d\u7684\u6570\u636e\u884c\u3002<\/p>\n<p>\u7d22\u5f15\u626b\u63cf\u5305\u542b\u805a\u96c6\u7d22\u5f15\u626b\u63cf\u548c\u4e8c\u7ea7\u7d22\u5f15\u626b\u63cf\u3002\u7531\u4e8e\u5728\u805a\u96c6\u7d22\u5f15\u4e2d\uff0c\u5305\u542b\u4e86\u8868\u4e2d\u6240\u6709\u7684\u5217\u503c\uff0c\u6240\u4ee5\u68c0\u7d22\u6570\u636e\u65f6\u53ea\u9700\u8981\u626b\u63cf\u8fd9\u4e00\u4e2a\u7d22\u5f15\u5c31\u53ef\u4ee5\u5f97\u5230\u6240\u6709\u9700\u8981\u7684\u6570\u636e\u3002\u5982\u679c\u662f\u4e8c\u7ea7\u7d22\u5f15\uff0c\u7531\u4e8e\u53ea\u5305\u542b\u7d22\u5f15\u5217\u4ee5\u53ca\u5bf9\u5e94\u7684 ROWID\uff0c\u5982\u679c\u67e5\u8be2\u5217\u4e0d\u5728\u4e8c\u7ea7\u7d22\u5f15\u4e2d\u5219\u8fd8\u9700\u8981\u626b\u63cf\u805a\u96c6\u7d22\u5f15\u6765\u5f97\u5230\u6240\u9700\u8981\u7684\u6570\u636e\u3002<\/p>\n<p>\u67e5\u8be2\u4f18\u5316\u5668\u9009\u62e9\u8bbf\u95ee\u8def\u5f84\u57fa\u4e8e\u4ee5\u4e0b\u51e0\u4e2a\u56e0\u7d20\uff1a<\/p>\n<ol>\n<li>\u6267\u884c\u8bed\u53e5\u4e2d\u53ef\u80fd\u7684\u8bbf\u95ee\u8def\u5f84\uff1b<\/li>\n<li>\u4f30\u7b97\u6bcf\u6761\u6267\u884c\u8def\u5f84\u7684\u4ee3\u4ef7\u3002\u4e3a\u4e86\u9009\u62e9\u4e00\u4e2a\u8bbf\u95ee\u8def\u5f84\uff0c\u4f18\u5316\u5668\u9996\u5148\u4f1a\u901a\u8fc7\u68c0\u67e5\u8bed\u53e5\u4e2d\u7684 FROM \u5b50\u53e5\u548c WHERE \u5b50\u53e5\u4e2d\u7684\u6761\u4ef6\u8868\u8fbe\u5f0f\u6765\u51b3\u5b9a\u54ea\u4e00\u4e2a\u8bbf\u95ee\u8def\u5f84\u53ef\u4ee5\u4f7f\u7528\u3002\u4f18\u5316\u5668\u4f1a\u6839\u636e\u53ef\u7528\u7684\u8bbf\u95ee\u8def\u5f84\u751f\u6210\u53ef\u80fd\u7684\u6267\u884c\u8ba1\u5212\u96c6\u5408\uff0c\u7136\u540e\u4f7f\u7528\u7d22\u5f15\u3001\u5217\u548c\u8868\u7684\u7edf\u8ba1\u4fe1\u606f\u6765\u4f30\u7b97\u6bcf\u4e2a\u8ba1\u5212\u7684\u4ee3\u4ef7\u3002\u6700\u540e\uff0c\u4f18\u5316\u5668\u9009\u62e9\u6700\u5c0f\u4ee3\u4ef7\u7684\u90a3\u4e2a\u6267\u884c\u8ba1\u5212\u3002<\/li>\n<\/ol>\n<p>\u5f71\u54cd\u4f18\u5316\u5668\u9009\u62e9\u8bbf\u95ee\u8def\u5f84\u7684\u56e0\u7d20\u6709\u8bed\u53e5\u4e2d\u7684\u63d0\u793a\uff08HINT\uff09\u548c\u7edf\u8ba1\u4fe1\u606f\u3002\u7528\u6237\u53ef\u4ee5\u5728\u6267\u884c\u7684\u8bed\u53e5\u4e2d\u4f7f\u7528 HINT \u6765\u6307\u5b9a\u8bbf\u95ee\u8def\u5f84\u3002\u800c\u7edf\u8ba1\u4fe1\u606f\u4f1a\u6839\u636e\u8868\u4e2d\u6570\u636e\u7684\u5206\u5e03\u60c5\u51b5\u51b3\u5b9a\u91c7\u7528\u54ea\u4e2a\u8bbf\u95ee\u8def\u5f84\u4f1a\u4ea7\u751f\u6700\u5c0f\u7684\u4ee3\u4ef7\u3002<\/p>\n<h2 id=\"22-4-\u8fde\u63a5\" class=\"article-heading\" style=\"position: relative;\">22.4 \u8fde\u63a5<a class=\"article-anchor\" href=\"#22.4 \u8fde\u63a5\" aria-hidden=\"true\"><\/a><\/p>\n<div id=\"22.4 \u8fde\u63a5\" style=\"position: absolute; top: -100px;\"><\/div>\n<\/h2>\n<p>\u67e5\u8be2\u8bed\u53e5\u4e2d FROM \u5b50\u53e5\u5305\u542b\u591a\u4e2a\u8868\u65f6\uff0c\u6211\u4eec\u79f0\u4e3a\u8fde\u63a5\u67e5\u8be2\u3002\u5982 SELECT * FROM t1,t2 \u5c31\u662f\u8fde\u63a5\u67e5\u8be2\u3002<\/p>\n<p>\u751f\u6210\u8fde\u63a5\u67e5\u8be2\u7684\u6267\u884c\u8ba1\u5212\uff0c\u9700\u8981\u8003\u8651\u4e09\u65b9\u9762\u56e0\u7d20\uff1a<\/p>\n<ol>\n<li><strong>\u8bbf\u95ee\u8def\u5f84<\/strong><\/li>\n<\/ol>\n<p>\u5bf9\u4e8e\u6bcf\u5f20\u8868\u91c7\u7528\u4f55\u79cd\u65b9\u5f0f\u6765\u83b7\u53d6\u6570\u636e\u3002\u4f8b\u5982\uff1a\u5168\u8868\u626b\u63cf\u3001\u7d22\u5f15\u626b\u63cf\u7b49\u3002<\/p>\n<p>\u67e5\u8be2\u4f18\u5316\u5668\u4f1a\u4f30\u7b97\u6bcf\u79cd\u626b\u63cf\u65b9\u5f0f\u7684\u4ee3\u4ef7\uff0c\u9009\u62e9\u4ee3\u4ef7\u8f83\u5c0f\u7684\u8bbf\u95ee\u8def\u5f84\u3002<\/p>\n<ol start=\"2\">\n<li><strong>\u8fde\u63a5\u65b9\u5f0f<\/strong><\/li>\n<\/ol>\n<p>\u786e\u5b9a\u4e24\u5f20\u8868\u4e4b\u95f4\u91c7\u7528\u54ea\u79cd\u8fde\u63a5\u65b9\u5f0f\u3002\u4f8b\u5982\uff1a\u54c8\u5e0c\u8fde\u63a5\u3001\u5d4c\u5957\u8fde\u63a5\u3001\u5f52\u5e76\u8fde\u63a5\u3001\u5916\u8fde\u63a5\u3002<\/p>\n<p>\u7b49\u503c\u8fde\u63a5\u6761\u4ef6\u4e00\u822c\u4f1a\u9009\u62e9\u54c8\u5e0c\u8fde\u63a5\uff1b\u975e\u7b49\u503c\u8fde\u63a5\u6761\u4ef6\u4f1a\u91c7\u7528\u5d4c\u5957\u8fde\u63a5\uff1b\u8fde\u63a5\u5217\u5747\u4e3a\u7d22\u5f15\u5217\u65f6\uff0c\u4f1a\u91c7\u7528\u5f52\u5e76\u8fde\u63a5\u3002<\/p>\n<ol>\n<li>\u5d4c\u5957\u8fde\u63a5\uff1a\u4e24\u5f20\u8868\u8fdb\u884c\u975e\u7b49\u503c\u8fde\u63a5\u65f6\u4f1a\u9009\u62e9\u5d4c\u5957\u8fde\u63a5\u3002\u76f8\u5f53\u4e8e\u4e24\u5f20\u8868\u8fdb\u884c\u7b1b\u5361\u5c14\u96c6\u64cd\u4f5c\u3002\u6b64\u65f6\uff0c\u4f18\u5316\u5668\u4f1a\u9009\u62e9\u4e00\u5f20\u4ee3\u4ef7\u8f83\u5c0f\u7684\u8868\u4f5c\u4e3a\u5916\u8868(\u9a71\u52a8\u8868)\uff0c\u53e6\u4e00\u5f20\u8868\u4f5c\u4e3a\u5185\u8868\uff0c\u5916\u8868\u7684\u6bcf\u6761\u8bb0\u5f55\u4e0e\u5185\u8868\u8fdb\u884c\u4e00\u6b21\u8fde\u63a5\u64cd\u4f5c\u3002<\/li>\n<li>\u54c8\u5e0c\u8fde\u63a5\uff1a\u4e24\u5f20\u8868\u8fdb\u884c\u7b49\u503c\u8fde\u63a5\u65f6\u4f1a\u9009\u62e9\u54c8\u5e0c\u8fde\u63a5\u3002\u4ee5\u4e00\u5f20\u8868\u7684\u8fde\u63a5\u5217\u4e3a\u54c8\u5e0c\u952e\uff0c\u6784\u9020\u54c8\u5e0c\u8868\uff0c\u53e6\u5f20\u8868\u7684\u8fde\u63a5\u5217\u8fdb\u884c\u54c8\u5e0c\u63a2\u6d4b\uff0c\u627e\u5230\u6ee1\u8db3\u6761\u4ef6\u7684\u8bb0\u5f55\u3002\u7531\u4e8e\u54c8\u5e0c\u547d\u4e2d\u7387\u9ad8\uff0c\u56e0\u6b64\uff0c\u5728\u5927\u6570\u636e\u91cf\u60c5\u51b5\u4e0b\uff0c\u54c8\u5e0c\u8fde\u63a5\u7684\u6548\u7387\u8f83\u9ad8\u3002\u54c8\u5e0c\u8fde\u63a5\u7684\u4ee3\u4ef7\u662f\u5efa\u7acb\u54c8\u5e0c\u8868\u548c\u54c8\u5e0c\u63a2\u6d4b\u7684\u4ee3\u4ef7\u3002<\/li>\n<li>\u5f52\u5e76\u8fde\u63a5\uff1a\u4e24\u5f20\u8868\u7684\u8fde\u63a5\u5217\u5747\u4e3a\u7d22\u5f15\u5217\uff0c\u5219\u53ef\u4ee5\u6309\u7167\u7d22\u5f15\u987a\u5e8f\u8fdb\u884c\u5f52\u5e76\uff0c\u4e00\u8d9f\u5f52\u5e76\u5c31\u53ef\u4ee5\u627e\u51fa\u6ee1\u8db3\u6761\u4ef6\u7684\u8bb0\u5f55\u3002\u5982\u679c\u67e5\u8be2\u5217\u4e5f\u5c5e\u4e8e\u7d22\u5f15\u5217\u7684\u5b50\u96c6\uff0c\u5219\u5f52\u5e76\u8fde\u63a5\u53ea\u9700\u626b\u63cf\u7d22\u5f15\uff0c\u4f1a\u6709\u66f4\u597d\u7684\u6027\u80fd\u8868\u73b0\u3002\u5728\u4e24\u8868\u8fde\u63a5\u6761\u4ef6\u4e0d\u662f\u7b49\u503c\uff08\u5982&lt;\uff0c&lt;=\uff0c&gt;\uff0c&gt;=\uff09\u60c5\u51b5\u4e0b\u65f6\uff0c\u5f52\u5e76\u6392\u5e8f\u8fde\u63a5\u5f88\u6709\u7528\u3002<\/li>\n<li>\u5916\u8fde\u63a5\uff1a\u5916\u8fde\u63a5\u5206\u4e3a\u5de6\u5916\u8fde\u63a5\u3001\u53f3\u5916\u8fde\u63a5\u3001\u5168\u5916\u8fde\u63a5\u3002\u4f5c\u4e3a\u5916\u8868\u7684\u6570\u636e\u4f1a\u5168\u90e8\u8fd4\u56de\uff0c\u5982\u679c\u6ca1\u6709\u4e0e\u5916\u8868\u5339\u914d\u7684\u8bb0\u5f55\uff0c\u5219\u586b\u5145 NULL \u503c\u3002\u53f3\u5916\u8fde\u63a5\u4e0e\u5de6\u5916\u8fde\u63a5\u7684\u5904\u7406\u8fc7\u7a0b\u7c7b\u4f3c\uff0c\u53ea\u662f\u5916\u8868\u4e0d\u540c\uff0c\u4e00\u4e2a\u662f\u5de6\u8868\uff0c\u4e00\u4e2a\u662f\u53f3\u8868\u3002\u5168\u5916\u8fde\u63a5\u662f\u8fdb\u884c\u5de6\u5916\u8fde\u63a5\u548c\u53f3\u5916\u8fde\u63a5\uff0c\u8fd4\u56de\u4e24\u6b21\u5916\u8fde\u63a5\u7684 union \u7ed3\u679c\u96c6\u3002<\/li>\n<\/ol>\n<p>\u4f8b 1 \u5de6\u5916\u8fde\u63a5<\/p>\n<pre><a class=\"btn-copy\" data-clipboard-target=\"\" style=\"text-align: center; float: right; margin-left: -64px; width: 64px; color: rgb(148, 163, 234); cursor: pointer; text-decoration: none; font-size: 13px; font-family: inherit; padding: 0px 0.3rem; position: relative; background: rgb(244, 244, 244); z-index: 9;\"><span>Copy<\/span><\/a><code class=\"language-plaintext hljs\" style=\"background: rgb(244, 244, 244);\">  SELECT * FROM t1 LEFT OUTER JOIN t2 ON t1.c1=t2.d1;\n<\/code><\/pre>\n<p>\u4f8b 1 \u4e2d t1 \u8868\u4e3a\u5916\u8868(\u5de6\u8868)\uff0c\u5982\u679c t2 \u8868\u4e2d\u4e0d\u5b58\u5728\u4e0e t1.c1 \u76f8\u7b49\u7684\u8bb0\u5f55\uff0ct2 \u8868\u7684\u8be5\u884c\u8bb0\u5f55\u7528 NULL \u586b\u5145\u3002\u53f3\u5916\u8fde\u63a5\u4e0e\u5de6\u5916\u7c7b\u4f3c\u3002<\/p>\n<p>\u4f8b 2  \u5168\u5916\u8fde\u63a5<\/p>\n<pre><a class=\"btn-copy\" data-clipboard-target=\"\" style=\"text-align: center; float: right; margin-left: -64px; width: 64px; color: rgb(148, 163, 234); cursor: pointer; text-decoration: none; font-size: 13px; font-family: inherit; padding: 0px 0.3rem; position: relative; background: rgb(244, 244, 244); z-index: 9;\"><span>Copy<\/span><\/a><code class=\"language-plaintext hljs\" style=\"background: rgb(244, 244, 244);\">  SELECT * FROM t1 FULL OUTER JOIN t2 ON t1.c1=t2.d1;\n<\/code><\/pre>\n<p>\u4f8b 2 \u4e2d\u5206\u522b\u4ee5 t1 \u4e3a\u5de6\u8868\u8fdb\u884c\u5de6\u5916\u548c\u53f3\u5916\u8fde\u63a5\uff0c\u4e24\u6b21\u7ed3\u679c\u8fdb\u884c union\uff0c\u8fd4\u56de\u6700\u7ec8\u7ed3\u679c\u3002<\/p>\n<p>\u5b50\u67e5\u8be2\u4f1a\u8f6c\u6362\u6210\u534a\u8fde\u63a5\u3002\u5171\u6709\u56db\u79cd\u534a\u8fde\u63a5\u65b9\u5f0f\uff1a\u54c8\u5e0c\u534a\u8fde\u63a5\u3001\u7d22\u5f15\u534a\u8fde\u63a5\u3001\u5d4c\u5957\u534a\u8fde\u63a5\u3001\u5f52\u5e76\u534a\u8fde\u63a5\u3002\u7b49\u503c\u8fde\u63a5\u6761\u4ef6\u4f1a\u9009\u62e9\u54c8\u5e0c\\\u7d22\u5f15\\\u5f52\u5e76\u534a\u8fde\u63a5\uff0c\u975e\u7b49\u503c\u8fde\u63a5\u6761\u4ef6\u4f1a\u9009\u62e9\u5d4c\u5957\u534a\u8fde\u63a5\u3002<\/p>\n<ol>\n<li>\u54c8\u5e0c\u534a\u8fde\u63a5\uff1a\u4ee5\u5916\u8868\u7684\u8fde\u63a5\u5217\u4e3a KEY \u6784\u9020\u54c8\u5e0c\u8868\uff0c\u5185\u8868\u7684\u8fde\u63a5\u5217\u8fdb\u884c\u63a2\u6d4b\u6765\u67e5\u627e\u6ee1\u8db3\u8fde\u63a5\u6761\u4ef6\u7684\u8bb0\u5f55\uff1b<\/li>\n<li>\u7d22\u5f15\u534a\u8fde\u63a5\uff1a\u5982\u679c\u5b50\u67e5\u8be2\u7684\u8fde\u63a5\u5217\u4e3a\u7d22\u5f15\u524d\u5bfc\u5217\uff0c\u53ef\u91c7\u7528\u7d22\u5f15\u534a\u8fde\u63a5\u3002\u5904\u7406\u8fc7\u7a0b\u4e3a\u5916\u8868\u7684\u6570\u636e\u5bf9\u5b50\u67e5\u8be2\u4f7f\u7528\u7d22\u5f15\u67e5\u627e\uff0c\u8fd4\u56de\u6ee1\u8db3\u6761\u4ef6\u7684\u8bb0\u5f55\uff1b<\/li>\n<li>\u5f52\u5e76\u534a\u8fde\u63a5\uff1a\u5982\u679c\u76f8\u5173\u5b50\u67e5\u8be2\u7684\u8fde\u63a5\u6761\u4ef6\u5217\u5747\u4e3a\u7d22\u5f15\u5217\uff0c\u53ef\u91c7\u7528\u5f52\u5e76\u534a\u8fde\u63a5\u3002\u6309\u7167 \u7d22\u5f15\u987a\u5e8f\uff0c\u5bf9\u5916\u8868\u3001\u5185\u8868\u8fdb\u884c\u540c\u6b65\u626b\u63cf\uff0c\u8fd4\u56de\u6ee1\u8db3\u6761\u4ef6\u7684\u8bb0\u5f55\uff1b<\/li>\n<li>\u5d4c\u5957\u534a\u8fde\u63a5\uff1a\u5982\u679c\u8fde\u63a5\u6761\u4ef6\u4e3a\u975e\u7b49\u503c\uff0c\u53ef\u8f6c\u6362\u4e3a\u5d4c\u5957\u534a\u8fde\u63a5\u3002\u5904\u7406\u8fc7\u7a0b\u4e3a\u5916\u8868\u7684\u6bcf\u6761\u8bb0\u5f55\u53bb\u904d\u5386\u5185\u8868\uff0c\u8fd4\u56de\u6ee1\u8db3\u6761\u4ef6\u7684\u8bb0\u5f55\u3002<\/li>\n<\/ol>\n<ol start=\"3\">\n<li><strong>\u8fde\u63a5\u987a\u5e8f<\/strong><\/li>\n<\/ol>\n<p>\u5f53\u8d85\u8fc7 2 \u5f20\u8868\u8fdb\u884c\u8fde\u63a5\u65f6\uff0c\u5c31\u9700\u8981\u8003\u8651\u8868\u4e4b\u95f4\u7684\u8fde\u63a5\u987a\u5e8f\u3002\u4e0d\u5408\u9002\u7684\u8fde\u63a5\u987a\u5e8f\u5bf9\u6267\u884c\u6548\u7387\u6709\u8f83\u5927\u5f71\u54cd\u3002\u4e00\u822c\u539f\u5219\u662f\uff0c\u7ecf\u8fc7\u8fde\u63a5\u53ef\u4ee5\u4ea7\u751f\u8f83\u5c0f\u7ed3\u679c\u96c6\u7684\u8868\u4f18\u5148\u5904\u7406\u3002<\/p>\n<p>\u4e00\u4e2a\u8fde\u63a5\u67e5\u8be2\u901a\u5e38\u4f1a\u5bf9\u5e94\u591a\u4e2a\u6267\u884c\u8ba1\u5212\uff0c\u67e5\u8be2\u4f18\u5316\u5668\u4f1a\u6839\u636e\u4f18\u5316\u89c4\u5219\u3001\u4ee3\u4ef7\u4f30\u7b97\u6311\u9009\u6700\u4f18\u7684\u6267\u884c\u8ba1\u5212\u3002<\/p>\n<h2 id=\"22-5-\u7edf\u8ba1\u4fe1\u606f\" class=\"article-heading\" style=\"position: relative;\">22.5 \u7edf\u8ba1\u4fe1\u606f<a class=\"article-anchor\" href=\"#22.5 \u7edf\u8ba1\u4fe1\u606f\" aria-hidden=\"true\"><\/a><\/p>\n<div id=\"22.5 \u7edf\u8ba1\u4fe1\u606f\" style=\"position: absolute; top: -100px;\"><\/div>\n<\/h2>\n<p>\u5bf9\u8c61\u7edf\u8ba1\u4fe1\u606f\u63cf\u8ff0\u4e86\u5bf9\u8c61\u6570\u636e\u7684\u5206\u5e03\u7279\u5f81\u3002\u7edf\u8ba1\u4fe1\u606f\u662f\u4f18\u5316\u5668\u7684\u4ee3\u4ef7\u8ba1\u7b97\u7684\u4f9d\u636e\uff0c\u53ef\u4ee5\u5e2e\u52a9\u4f18\u5316\u5668\u8f83\u7cbe\u786e\u5730\u4f30\u7b97\u6210\u672c\uff0c\u5bf9\u6267\u884c\u8ba1\u5212\u7684\u9009\u62e9\u8d77\u7740\u81f3\u5173\u91cd\u8981\u7684\u4f5c\u7528\u3002\u7edf\u8ba1\u4fe1\u606f\u7684\u6536\u96c6\u9891\u7387\u662f\u4e00\u628a\u53cc\u5203\u5251\uff0c\u9891\u7387\u592a\u4f4e\u5bfc\u81f4\u7edf\u8ba1\u4fe1\u606f\u6ede\u540e\uff0c\u9891\u7387\u592a\u9ad8\u53c8\u5f71\u54cd\u67e5\u8be2\u6027\u80fd\uff0c\u56e0\u6b64\uff0c\u7cfb\u7edf\u7ba1\u7406\u5458\u9700\u8981\u6839\u636e\u5b9e\u9645\u60c5\u51b5\uff0c\u5408\u7406\u5b89\u6392\u7edf\u8ba1\u4fe1\u606f\u6536\u96c6\u7684\u9891\u7387\u3002<\/p>\n<h3 id=\"22-5-1-\u7edf\u8ba1\u4fe1\u606f\u7b80\u4ecb\" class=\"article-heading\" style=\"position: relative;\">22.5.1 \u7edf\u8ba1\u4fe1\u606f\u7b80\u4ecb<a class=\"article-anchor\" href=\"#22.5.1 \u7edf\u8ba1\u4fe1\u606f\u7b80\u4ecb\" aria-hidden=\"true\"><\/a><\/p>\n<div id=\"22.5.1 \u7edf\u8ba1\u4fe1\u606f\u7b80\u4ecb\" style=\"position: absolute; top: -100px;\"><\/div>\n<\/h3>\n<h4 id=\"22-5-1-1-\u79cd\u7c7b\" class=\"article-heading\" style=\"position: relative;\">22.5.1.1 \u79cd\u7c7b<a class=\"article-anchor\" href=\"#22.5.1.1 \u79cd\u7c7b\" aria-hidden=\"true\"><\/a><\/p>\n<div id=\"22.5.1.1 \u79cd\u7c7b\" style=\"position: absolute; top: -100px;\"><\/div>\n<\/h4>\n<p>\u8fbe\u68a6\u6570\u636e\u5e93\u7684\u7edf\u8ba1\u6570\u636e\u5bf9\u8c61\u5206\u4e09\u79cd\uff1a\u8868\u7edf\u8ba1\u4fe1\u606f\u3001\u5217\u7edf\u8ba1\u4fe1\u606f\u548c\u7d22\u5f15\u7edf\u8ba1\u4fe1\u606f\u3002\u7edf\u8ba1\u4fe1\u606f\u751f\u6210\u8fc7\u7a0b\u5206\u4e09\u4e2a\u6b65\u9aa4\uff1a<\/p>\n<ol>\n<li>\u786e\u5b9a\u91c7\u6837\u7684\u5bf9\u8c61\uff1a\u6839\u636e\u6570\u636e\u5bf9\u8c61\uff0c\u786e\u5b9a\u9700\u8981\u5206\u6790\u54ea\u4e9b\u6570\u636e\u3002<br \/>\n1\uff09\u8868\uff1a\u8ba1\u7b97\u8868\u7684\u884c\u6570\u3001\u6240\u5360\u7684\u9875\u6570\u76ee\u3001\u5e73\u5747\u8bb0\u5f55\u957f\u5ea6\u3002<br \/>\n2\uff09\u5217\uff1a\u7edf\u8ba1\u5217\u6570\u636e\u7684\u5206\u5e03\u7279\u5f81\u3002<br \/>\n3\uff09\u7d22\u5f15\uff1a\u7edf\u8ba1\u7d22\u5f15\u5217\u7684\u6570\u636e\u5206\u5e03\u7279\u5f81\u3002<\/li>\n<li>\u786e\u5b9a\u91c7\u6837\u7387\u3002\u7528\u6237\u6839\u636e\u7edf\u8ba1\u6570\u636e\u5bf9\u8c61\u7684\u5927\u5c0f\uff0c\u786e\u5b9a\u91c7\u6837\u7387\u3002\u5982\u7f3a\u7701\uff0c\u5219\u9ed8\u8ba4\u901a\u8fc7\u5185\u90e8\u7b97\u6cd5\u786e\u5b9a\u6570\u636e\u7684\u91c7\u6837\u7387\u3002<\/li>\n<li>\u751f\u6210\u7edf\u8ba1\u4fe1\u606f\u3002\u6839\u636e\u4e0d\u540c\u7684\u6570\u636e\u5bf9\u8c61\u751f\u6210\u4e0d\u540c\u7684\u7edf\u8ba1\u4fe1\u606f\u3002<br \/>\n1\uff09\u8868\uff1a\u8868\u7684\u884c\u6570\u3001\u6240\u5360\u7684\u9875\u6570\u76ee\u3001\u5e73\u5747\u8bb0\u5f55\u957f\u5ea6\u7b49\u6c47\u603b\u6570\u636e\u3002<br \/>\n2\uff09\u5217\u548c\u7d22\u5f15\uff1a\u5c06\u91c7\u6837\u7684\u6570\u636e\u6309\u7167\u4e0d\u540c\u7684\u5206\u5e03\u7279\u5f81\u751f\u6210\u76f8\u5e94\u7684\u76f4\u65b9\u56fe\u3002\u6709\u4e24\u79cd\u7c7b\u578b\u7684\u76f4\u65b9\u56fe\uff1a\u9891\u7387\u76f4\u65b9\u56fe\u548c\u7b49\u9ad8\u76f4\u65b9\u56fe\u3002\u6839\u636e\u7b97\u6cd5\u5206\u6790\u8868\u7684\u6570\u636e\u5206\u5e03\u7279\u5f81\uff08\u4ee5\u4e0d\u540c\u503c\u7684\u6570\u636e\u91cf 1 \u4e07\u4e2a\u4e3a\u5206\u754c\u7ebf\uff09\uff0c\u786e\u5b9a\u76f4\u65b9\u56fe\u7684\u7c7b\u578b\u3002\u9891\u7387\u76f4\u65b9\u56fe\u7684\u6bcf\u4e2a\u6876(\u4fdd\u5b58\u7edf\u8ba1\u4fe1\u606f\u7684\u5bf9\u8c61)\u7684\u9ad8\u5ea6\u4e0d\u540c\uff0c\u7b49\u9ad8\u76f4\u65b9\u56fe\u6bcf\u4e2a\u6876\u7684\u9ad8\u5ea6\u76f8\u540c\u3002\u751f\u6210\u76f4\u65b9\u56fe\u65f6\uff0c\u5982\u679c\u4e0d\u540c\u503c\u5c11\u4e8e 1 \u4e07\u4e2a\u5219\u7528\u9891\u7387\u76f4\u65b9\u56fe\uff0c\u5426\u5219\u7528\u7b49\u9ad8\u76f4\u65b9\u56fe\u3002<\/li>\n<\/ol>\n<h4 id=\"22-5-1-2-\u4f5c\u7528\" class=\"article-heading\" style=\"position: relative;\">22.5.1.2 \u4f5c\u7528<a class=\"article-anchor\" href=\"#22.5.1.2 \u4f5c\u7528\" aria-hidden=\"true\"><\/a><\/p>\n<div id=\"22.5.1.2 \u4f5c\u7528\" style=\"position: absolute; top: -100px;\"><\/div>\n<\/h4>\n<p>\u5728\u6267\u884c\u67e5\u8be2\u65f6\uff0c\u5982\u679c\u6570\u636e\u5bf9\u8c61\u5b58\u5728\u7edf\u8ba1\u4fe1\u606f\uff0c\u4ee3\u4ef7\u7b97\u6cd5\u53ef\u4ee5\u6839\u636e\u7edf\u8ba1\u4fe1\u606f\u4e2d\u7684\u6570\u636e\uff0c\u6bd4\u8f83\u7cbe\u786e\u5730\u8ba1\u7b97\u51fa\u64cd\u4f5c\u6240\u9700\u82b1\u8d39\u7684\u6210\u672c\uff0c\u4ee5\u6b64\u6765\u786e\u5b9a\u8fde\u63a5\u65b9\u5f0f\u3001\u5bf9\u8c61\u8bbf\u95ee\u8def\u5f84\u3001\u8fde\u63a5\u987a\u5e8f\uff0c\u9009\u62e9\u6700\u4f18\u7684\u6267\u884c\u8ba1\u5212\u3002<\/p>\n<h4 id=\"22-5-1-3-\u6536\u96c6\u65f6\u673a\" class=\"article-heading\" style=\"position: relative;\">22.5.1.3 \u6536\u96c6\u65f6\u673a<a class=\"article-anchor\" href=\"#22.5.1.3 \u6536\u96c6\u65f6\u673a\" aria-hidden=\"true\"><\/a><\/p>\n<div id=\"22.5.1.3 \u6536\u96c6\u65f6\u673a\" style=\"position: absolute; top: -100px;\"><\/div>\n<\/h4>\n<p>\u6536\u96c6\u7edf\u8ba1\u4fe1\u606f\u7684\u65f6\u673a\u6709\u4e24\u79cd\uff1a\u4e00\u662f\u5728\u67e5\u8be2\u4e4b\u524d\u8fdb\u884c\u9759\u6001\u6536\u96c6\uff1b\u4e8c\u662f\u5728\u67e5\u8be2\u7684\u540c\u65f6\u8fdb\u884c\u52a8\u6001\u6536\u96c6\u3002<\/p>\n<p>\u9759\u6001\u6536\u96c6\u662f\u5728\u67e5\u8be2\u4e4b\u524d\u5b8c\u6210\u3002\u548c\u67e5\u8be2\u64cd\u4f5c\u4e92\u4e0d\u5e72\u6d89\uff0c\u56e0\u6b64\u4e0d\u5f71\u54cd\u67e5\u8be2\u6027\u80fd\u3002<\/p>\n<p>\u52a8\u6001\u6536\u96c6\u662f\u5728\u67e5\u8be2\u7684\u8fc7\u7a0b\u4e2d\u5b8c\u6210\u3002\u5177\u4f53\u4e3a\u5728\u6784\u9020\u67e5\u8be2\u8ba1\u5212\u9636\u6bb5\u8fdb\u884c\uff0c\u7edf\u8ba1\u4fe1\u606f\u6536\u96c6\u5b8c\u6210\u4e4b\u540e\u518d\u7ee7\u7eed\u6784\u9020\u8ba1\u5212\uff0c\u56e0\u6b64\u4f1a\u5f71\u54cd\u8ba1\u5212\u9636\u6bb5\u6027\u80fd\uff0c\u7279\u522b\u662f\u5728\u9ad8\u5e76\u53d1\u573a\u666f\u4e2d\u3002<\/p>\n<p>\u4ece\u6027\u80fd\u89d2\u5ea6\u8003\u8651\uff0c\u63a8\u8350\u7528\u6237\u4f7f\u7528\u9759\u6001\u6536\u96c6\u3002<\/p>\n<h3 id=\"22-5-2-\u7edf\u8ba1\u4fe1\u606f\u7528\u6cd5\" class=\"article-heading\" style=\"position: relative;\">22.5.2 \u7edf\u8ba1\u4fe1\u606f\u7528\u6cd5<a class=\"article-anchor\" href=\"#22.5.2 \u7edf\u8ba1\u4fe1\u606f\u7528\u6cd5\" aria-hidden=\"true\"><\/a><\/p>\n<div id=\"22.5.2 \u7edf\u8ba1\u4fe1\u606f\u7528\u6cd5\" style=\"position: absolute; top: -100px;\"><\/div>\n<\/h3>\n<p>\u7edf\u8ba1\u4fe1\u606f\u7684\u4f7f\u7528\u65b9\u6cd5\u6709\uff1a\u6536\u96c6\u7edf\u8ba1\u4fe1\u606f\uff08\u9759\u6001\u6216\u52a8\u6001\uff09\u3001\u67e5\u770b\u7edf\u8ba1\u4fe1\u606f\u548c\u76d1\u63a7\u7edf\u8ba1\u4fe1\u606f\u7b49\u3002<\/p>\n<h4 id=\"22-5-2-1-\u6536\u96c6\u7edf\u8ba1\u4fe1\u606f\" class=\"article-heading\" style=\"position: relative;\">22.5.2.1 \u6536\u96c6\u7edf\u8ba1\u4fe1\u606f<a class=\"article-anchor\" href=\"#22.5.2.1 \u6536\u96c6\u7edf\u8ba1\u4fe1\u606f\" aria-hidden=\"true\"><\/a><\/p>\n<div id=\"22.5.2.1 \u6536\u96c6\u7edf\u8ba1\u4fe1\u606f\" style=\"position: absolute; top: -100px;\"><\/div>\n<\/h4>\n<h5 id=\"22-5-2-1-1---\u9759\u6001\u6536\u96c6\" class=\"article-heading\" style=\"position: relative;\">22.5.2.1.1   \u9759\u6001\u6536\u96c6<a class=\"article-anchor\" href=\"#22.5.2.1.1 \u9759\u6001\u6536\u96c6\" aria-hidden=\"true\"><\/a><\/p>\n<div id=\"22.5.2.1.1 \u9759\u6001\u6536\u96c6\" style=\"position: absolute; top: -100px;\"><\/div>\n<\/h5>\n<p>\u9759\u6001\u6536\u96c6\u7edf\u8ba1\u4fe1\u606f\u6709\u4e24\u79cd\u65b9\u5f0f\u3002\u4e00\u662f\u81ea\u52a8\u6536\u96c6\uff1b\u4e8c\u662f\u624b\u52a8\u6536\u96c6\u3002\u91c7\u7528\u4efb\u610f\u4e00\u79cd\u5373\u53ef\u3002\u9759\u6001\u6536\u96c6\u7684\u7ed3\u679c\u5747\u4f1a\u4fdd\u5b58\u5230\u7cfb\u7edf\u8868\u4e2d\u3002<\/p>\n<h6 id=\"22-5-2-1-1-1\u81ea\u52a8\u6536\u96c6\" class=\"article-heading\" style=\"position: relative;\">22.5.2.1.1.1 \u81ea\u52a8\u6536\u96c6<a class=\"article-anchor\" href=\"#22.5.2.1.1.1 \u81ea\u52a8\u6536\u96c6\" aria-hidden=\"true\"><\/a><\/p>\n<div id=\"22.5.2.1.1.1 \u81ea\u52a8\u6536\u96c6\" style=\"position: absolute; top: -100px;\"><\/div>\n<\/h6>\n<p>\u5728 INI \u53c2\u6570 AUTO_STAT_OBJ \u4e3a 1 \u6216 2 \u524d\u63d0\u4e0b\uff0c\u6267\u884c SP_CREATE_AUTO_STAT_ TRIGGER \u8fc7\u7a0b\u5b9e\u73b0\u81ea\u52a8\u6536\u96c6\u3002<\/p>\n<h6 id=\"22-5-2-1-1-2\u624b\u52a8\u6536\u96c6\" class=\"article-heading\" style=\"position: relative;\">22.5.2.1.1.2 \u624b\u52a8\u6536\u96c6<a class=\"article-anchor\" href=\"#22.5.2.1.1.2 \u624b\u52a8\u6536\u96c6\" aria-hidden=\"true\"><\/a><\/p>\n<div id=\"22.5.2.1.1.2 \u624b\u52a8\u6536\u96c6\" style=\"position: absolute; top: -100px;\"><\/div>\n<\/h6>\n<p>\u624b\u52a8\u6536\u96c6\u6709\u4e09\u79cd\u53ef\u9009\u65b9\u5f0f\u3002\u4e0b\u9762\u5206\u522b\u4ecb\u7ecd\uff1a<\/p>\n<ol>\n<li>\u901a\u8fc7\u300aDM8 \u7cfb\u7edf\u5305\u4f7f\u7528\u624b\u518c\u300b\u91cc DBMS_STATS \u5305\u4e2d\u7684\u65b9\u6cd5\uff08GATHER_TABLE_STATS\u3001GATHER_INDEX_STATS \u6216 GATHER_SCHEMA_STATS\uff09\u8fdb\u884c\u751f\u6210\u5e76\u6536\u96c6\u7edf\u8ba1\u4fe1\u606f\u3002<\/li>\n<li>\u901a\u8fc7\u300aDM8_SQL \u8bed\u8a00\u4f7f\u7528\u624b\u518c\u300b\u4e2d\u8bbe\u7f6e STAT \u8bed\u6cd5\u4e3a\u8868\u3001\u5217\u3001\u7d22\u5f15\u751f\u6210\u7edf\u8ba1\u4fe1\u606f\u3002<\/li>\n<\/ol>\n<p>\u4f8b \u5bf9 SYSOBJECTS \u8868\u4e0a ID \u5217\u751f\u6210\u7edf\u8ba1\u4fe1\u606f\uff0c\u91c7\u6837\u7387\u7684\u767e\u5206\u6bd4\u4e3a 30%\u3002\u4f7f\u7528\u6309\u65b0\u6bd4\u4f8b\u6536\u96c6\u7684\u5217\u7edf\u8ba1\u4fe1\u606f\u8986\u76d6\u4e4b\u524d\u8001\u7684\u7edf\u8ba1\u4fe1\u606f\u3002<\/p>\n<pre><a class=\"btn-copy\" data-clipboard-target=\"\" style=\"text-align: center; float: right; margin-left: -64px; width: 64px; color: rgb(148, 163, 234); cursor: pointer; text-decoration: none; font-size: 13px; font-family: inherit; padding: 0px 0.3rem; position: relative; background: rgb(244, 244, 244); z-index: 9;\"><span>Copy<\/span><\/a><code class=\"language-plaintext hljs\" style=\"background: rgb(244, 244, 244);\">STAT 30 ON SYS.SYSOBJECTS (ID);\n<\/code><\/pre>\n<ol start=\"3\">\n<li>\u901a\u8fc7\u300aDM8_SQL \u8bed\u8a00\u4f7f\u7528\u624b\u518c\u300b\u9644\u5f55 3 \u4e2d\u7edf\u8ba1\u4fe1\u606f\u7ae0\u8282\u7684\u7cfb\u7edf\u5b58\u50a8\u8fc7\u7a0b\u548c\u51fd\u6570\u8fdb\u884c\u751f\u6210\u3002<\/li>\n<\/ol>\n<p>\u4f8b \u5bf9 SYSOBJECTS \u8868\u4e0a\u6240\u6709\u7684\u7d22\u5f15\u751f\u6210\u7edf\u8ba1\u4fe1\u606f\u3002<\/p>\n<pre><a class=\"btn-copy\" data-clipboard-target=\"\" style=\"text-align: center; float: right; margin-left: -64px; width: 64px; color: rgb(148, 163, 234); cursor: pointer; text-decoration: none; font-size: 13px; font-family: inherit; padding: 0px 0.3rem; position: relative; background: rgb(244, 244, 244); z-index: 9;\"><span>Copy<\/span><\/a><code class=\"language-plaintext hljs\" style=\"background: rgb(244, 244, 244);\">CALL SP_TAB_INDEX_STAT_INIT ('SYS', 'SYSOBJECTS');\n<\/code><\/pre>\n<h5 id=\"22-5-2-1-2---\u52a8\u6001\u6536\u96c6\" class=\"article-heading\" style=\"position: relative;\">22.5.2.1.2   \u52a8\u6001\u6536\u96c6<a class=\"article-anchor\" href=\"#22.5.2.1.2 \u52a8\u6001\u6536\u96c6\" aria-hidden=\"true\"><\/a><\/p>\n<div id=\"22.5.2.1.2 \u52a8\u6001\u6536\u96c6\" style=\"position: absolute; top: -100px;\"><\/div>\n<\/h5>\n<p>\u5f53\u5df2\u6536\u96c6\u7684\u7edf\u8ba1\u4fe1\u606f\u5931\u6548\u6216\u672a\u66fe\u6536\u96c6\u65f6\uff0c\u7528\u6237\u53ef\u901a\u8fc7\u914d\u7f6e DM.INI \u53c2\u6570 OPTIMIZER_DYNAMIC_SAMPLING\uff0c\u5f00\u542f\u52a8\u6001\u6536\u96c6\u7edf\u8ba1\u4fe1\u606f\u3002<\/p>\n<p>OPTIMIZER_DYNAMIC_SAMPLING \u4e3a\u52a8\u6001\u4f1a\u8bdd\u7ea7\u53c2\u6570\uff0c\u53d6\u503c\u8303\u56f4\uff1a0~12\u30020\uff1a\u4e0d\u542f\u7528\uff1b1~10\uff1a\u542f\u7528\uff0c\u91c7\u7528\u7387 10%~100%\uff0c\u6536\u96c6\u52a8\u6001\u7edf\u8ba1\u4fe1\u606f\uff0c\u4f46\u6536\u96c6\u7ed3\u679c\u4e0d\u4f1a\u4fdd\u5b58\u5230\u7cfb\u7edf\u8868\uff1b11\uff1a\u542f\u7528\uff0c\u7531\u4f18\u5316\u5668\u81ea\u52a8\u786e\u5b9a\u91c7\u6837\u7387\uff080.1%~99.9%\uff09\uff0c\u6536\u96c6\u7ed3\u679c\u4e5f\u4e0d\u4f1a\u4fdd\u5b58\u5230\u7cfb\u7edf\u8868\uff1b12\uff1a\u548c 11 \u76f8\u540c\uff0c\u4f46\u6536\u96c6\u7684\u7ed3\u679c\u4f1a\u4fdd\u5b58\u5230\u7cfb\u7edf\u8868\u3002<\/p>\n<h4 id=\"22-5-2-2-\u67e5\u770b\u7edf\u8ba1\u4fe1\u606f\" class=\"article-heading\" style=\"position: relative;\">22.5.2.2 \u67e5\u770b\u7edf\u8ba1\u4fe1\u606f<a class=\"article-anchor\" href=\"#22.5.2.2 \u67e5\u770b\u7edf\u8ba1\u4fe1\u606f\" aria-hidden=\"true\"><\/a><\/p>\n<div id=\"22.5.2.2 \u67e5\u770b\u7edf\u8ba1\u4fe1\u606f\" style=\"position: absolute; top: -100px;\"><\/div>\n<\/h4>\n<p>\u6267\u884c\u8fc7\u751f\u6210\u7edf\u8ba1\u4fe1\u606f\u64cd\u4f5c\u540e\uff0c\u53ef\u901a\u8fc7\u4e0b\u9762\u591a\u79cd\u65b9\u5f0f\u67e5\u770b\u5230\u5177\u4f53\u7684\u7edf\u8ba1\u4fe1\u606f\u3002\u5176\u4e2d\uff0c\u52a8\u6001\u6536\u96c6\u4e2d\u53ea\u6709 OPTIMIZER_DYNAMIC_SAMPLING=12 \u53ef\u4ee5\u88ab\u67e5\u8be2\u5230\u3002<\/p>\n<ol>\n<li>\u7cfb\u7edf\u8868 SYSSTATS<\/li>\n<\/ol>\n<p>\u7528\u4e8e\u6267\u884c\u6536\u96c6\u7edf\u8ba1\u4fe1\u606f\u64cd\u4f5c\u4e4b\u540e\uff0c\u8bb0\u5f55\u7cfb\u7edf\u4e2d\u7684\u7edf\u8ba1\u4fe1\u606f\u3002<\/p>\n<ol start=\"2\">\n<li>\u7cfb\u7edf\u8868 SYSMSTATS<\/li>\n<\/ol>\n<p>\u8bb0\u5f55\u591a\u7ef4\u7edf\u8ba1\u4fe1\u606f\u7684\u5185\u5bb9\u3002<\/p>\n<ol start=\"3\">\n<li>\u7cfb\u7edf\u8868 SYSSTATPREFS<\/li>\n<\/ol>\n<p>\u8bb0\u5f55\u6307\u5b9a\u6a21\u5f0f\u4e0b\u8868\u7684\u7edf\u8ba1\u4fe1\u606f\u7684\u9759\u6001\u53c2\u6570\u5bf9\u5e94\u7684\u503c\u3002<\/p>\n<ol start=\"4\">\n<li>\u7cfb\u7edf\u8868 SYSSTATTABLEIDU<\/li>\n<\/ol>\n<p>\u8bb0\u5f55\u7528\u6237\u8868\u4e0a\u4e00\u6b21\u6536\u96c6\u7edf\u8ba1\u4fe1\u606f\u65f6\u7684\u603b\u884c\u6570\u548c\u589e\u5220\u6539\u7684\u5f71\u54cd\u884c\u6570\u4ee5\u53ca\u662f\u5426\u6709\u8fc7 TRUNCATE \u64cd\u4f5c\u3002<\/p>\n<ol start=\"5\">\n<li>\u901a\u8fc7 DBMS_STATS \u5305\u4e2d COLUMN_STATS_SHOW\u3001TABLE_STATS_SHOW \u548c INDEX_STATS_SHOW \u67e5\u770b\u8868\u3001\u5217\u3001\u7d22\u5f15\u7684\u7edf\u8ba1\u4fe1\u606f\u3002\u53ea\u6709\u7528\u8fc7 DBMS_STATS \u5305\u4e2d GATHER_TABLE_STATS\u3001GATHER_INDEX_STATS \u6216 GATHER_SCHEMA_STATS \u751f\u6210\u6536\u96c6\u64cd\u4f5c\u4e4b\u540e\u624d\u80fd\u67e5\u770b\u5230\u7ed3\u679c\u3002<\/li>\n<\/ol>\n<h4 id=\"22-5-2-3-\u76d1\u63a7\u7edf\u8ba1\u8fc7\u7a0b\" class=\"article-heading\" style=\"position: relative;\">22.5.2.3 \u76d1\u63a7\u7edf\u8ba1\u8fc7\u7a0b<a class=\"article-anchor\" href=\"#22.5.2.3 \u76d1\u63a7\u7edf\u8ba1\u8fc7\u7a0b\" aria-hidden=\"true\"><\/a><\/p>\n<div id=\"22.5.2.3 \u76d1\u63a7\u7edf\u8ba1\u8fc7\u7a0b\" style=\"position: absolute; top: -100px;\"><\/div>\n<\/h4>\n<p>\u652f\u6301\u5bf9\u81ea\u52a8\u6536\u96c6\u7edf\u8ba1\u4fe1\u606f\u7684\u8fc7\u7a0b\u8fdb\u884c\u76d1\u63a7\u3002<\/p>\n<p>\u901a\u8fc7\u521b\u5efa\u786e\u5b9a\u7684\u8fc7\u7a0b SYSDBA.GET_AUTO_STAT_INFO_FUNC\uff0c\u7528\u4ee5\u63a5\u6536\u670d\u52a1\u5668\u5728\u81ea\u52a8\u6536\u96c6\u7edf\u8ba1\u4fe1\u606f\u65f6\u7684\u76f8\u5173\u4fe1\u606f\u3002\u8be5\u8fc7\u7a0b\u7684\u6a21\u5757\u4f53\u4e3a\u5f00\u653e\u5f0f\uff0c\u7528\u6237\u53ef\u4ee5\u6839\u636e\u81ea\u5df1\u7684\u9700\u6c42\u6765\u7f16\u5199\u5982\u4f55\u4f7f\u7528\u7edf\u8ba1\u4fe1\u606f\u7684\u4ee3\u7801\u3002<\/p>\n<p><strong>\u8bed\u6cd5\u5982\u4e0b\uff1a<\/strong><\/p>\n<pre><a class=\"btn-copy\" data-clipboard-target=\"\" style=\"text-align: center; float: right; margin-left: -64px; width: 64px; color: rgb(148, 163, 234); cursor: pointer; text-decoration: none; font-size: 13px; font-family: inherit; padding: 0px 0.3rem; position: relative; background: rgb(244, 244, 244); z-index: 9;\"><span>Copy<\/span><\/a><code class=\"language-plaintext hljs\" style=\"background: rgb(244, 244, 244);\">CREATE OR REPLACE PROCEDURE  SYSDBA.GET_AUTO_STAT_INFO_FUNC(\nTASK_ID INT,\nTOTAL_STAT INT,\nTABLE_ID INT, \nSCH_NAME VARCHAR(24), \nTABLE_NAME VARCHAR(24),\nCURR_GATH_TAB_ID INT, \nCURR_GATH_SCH_NAME VARCHAR(24), \nCURR_GATH_TAB_NAME VARCHAR(24),\nSUCCESS_STAT INT,\nFAIL_STAT INT,\nTASK_START_TIME DATETIME, \nTASK_END_TIME DATETIME,\nGATHER_TBL_START_TIME DATETIME,\nGATHER_TBL_END_TIME DATETIME\n) AS\nBEGIN\n\/*\u7528\u6237\u81ea\u5b9a\u4e49\u5982\u4f55\u4f7f\u7528\u7edf\u8ba1\u4fe1\u606f\u7684\u4ee3\u7801*\/\nEND;\n\/\n<\/code><\/pre>\n<p><strong>\u53c2\u6570\u8be6\u89e3<\/strong><\/p>\n<p>\u25cf task_id \u4efb\u52a1 id\uff0c\u540c\u4e00\u4e2a\u4efb\u52a1\u7684 task_id \u76f8\u540c\u3002<\/p>\n<p>\u25cf total_stat \u4e00\u6b21\u4efb\u52a1\u9700\u8981\u6536\u96c6\u7684\u8868\u7684\u603b\u4e2a\u6570\u3002<\/p>\n<p>\u25cf table_id \u6536\u96c6\u5b8c\u6210\u7684\u4e00\u4e2a\u8868 table \u7684 id\uff0c\u6bcf\u6536\u96c6\u5b8c\u4e00\u4e2a\u8868\u7684\u7edf\u8ba1\u4fe1\u606f\uff0c\u5c31\u4f1a\u8c03\u7528\u4e00\u6b21 SYSDBA.GET_AUTO_STAT_INFO_FUNC\uff0c\u4f20\u51fa\u4e00\u6b21\u6570\u636e\uff0c\u7528\u6237\u53ef\u81ea\u5b9a\u4e49\u8be5\u8fc7\u7a0b\uff0c\u81ea\u5b9a\u4e49\u5904\u7406\u63a5\u6536\u5230\u7684\u6570\u636e\u3002<\/p>\n<p>\u25cf sch_name \u5bf9\u5e94 table_id \u7684\u6a21\u5f0f\u540d\u3002<\/p>\n<p>\u25cf table_name \u5bf9\u5e94 table_id \u7684\u8868\u540d\u3002<\/p>\n<p>\u25cf curr_gath_tab_id \u5f53\u524d\u6b63\u5728\u6536\u96c6\u7684\u8868 id\u3002\u6536\u96c6\u5b8c\u4e00\u4e2a\u8868 table \u540e\uff0c\u4f20\u51fa\u6570\u636e\u65f6\uff0c\u8be5\u5b57\u6bb5\u4e3a\u63a5\u4e0b\u6765\u8981\u6536\u96c6\u7684\u8868 id\uff0c\u4e5f\u662f\u670d\u52a1\u5668\u5f53\u524d\u6b63\u8981\u6216\u6b63\u5728\u6536\u96c6\u7684\u8868\u3002<\/p>\n<p>\u25cf curr_gath_sch_name \u5bf9\u5e94 curr_gath_tab_id \u7684\u6a21\u5f0f\u540d\u3002<\/p>\n<p>\u25cf curr_gath_tab_name \u5bf9\u5e94 curr_gath_tab_id \u7684\u8868\u540d\u3002<\/p>\n<p>\u25cf success_stat \u622a\u6b62\u5230\u76ee\u524d\u8fd9\u6b21\u6536\u96c6\u4efb\u52a1\u4e00\u5171\u6210\u529f\u6536\u96c6\u4e86\u591a\u5c11\u5f20\u8868\u3002<\/p>\n<p>\u25cf fail_stat \u622a\u6b62\u5230\u76ee\u524d\u8fd9\u6b21\u6536\u96c6\u4efb\u52a1\u4e00\u5171\u5931\u8d25\u6536\u96c6\u4e86\u591a\u5c11\u5f20\u8868\u3002<\/p>\n<p>\u25cf task_start_time \u8fd9\u6b21\u4efb\u52a1\u7684\u5f00\u59cb\u65f6\u95f4\u3002<\/p>\n<p>\u25cf task_end_time \u8fd9\u6b21\u4efb\u52a1\u7684\u7ed3\u675f\u65f6\u95f4\uff0c\u672a\u7ed3\u675f\u4e3a NULL\u3002<\/p>\n<p>\u25cf gather_tbl_start_time \u6536\u96c6\u5b8c\u4e00\u4e2a\u8868 table \u65f6\uff0c\u8be5\u8868\u6536\u96c6\u7684\u5f00\u59cb\u65f6\u95f4\u3002<\/p>\n<p>\u25cf gather_tbl_end_time \u6536\u96c6\u5b8c\u4e00\u4e2a\u8868 table \u65f6\uff0c\u8be5\u8868\u6536\u96c6\u7684\u7ed3\u675f\u65f6\u95f4\uff0c\u6536\u96c6\u5931\u8d25\uff0c\u5219\u7ed3\u675f\u65f6\u95f4\u4e3a NULL\u3002<\/p>\n<h3 id=\"22-5-3-\u5e94\u7528\u5b9e\u4f8b\" class=\"article-heading\" style=\"position: relative;\">22.5.3 \u5e94\u7528\u5b9e\u4f8b<a class=\"article-anchor\" href=\"#22.5.3 \u5e94\u7528\u5b9e\u4f8b\" aria-hidden=\"true\"><\/a><\/p>\n<div id=\"22.5.3 \u5e94\u7528\u5b9e\u4f8b\" style=\"position: absolute; top: -100px;\"><\/div>\n<\/h3>\n<h4 id=\"22-5-3-1-\u81ea\u52a8\u6536\u96c6\" class=\"article-heading\" style=\"position: relative;\">22.5.3.1 \u81ea\u52a8\u6536\u96c6<a class=\"article-anchor\" href=\"#22.5.3.1 \u81ea\u52a8\u6536\u96c6\" aria-hidden=\"true\"><\/a><\/p>\n<div id=\"22.5.3.1 \u81ea\u52a8\u6536\u96c6\" style=\"position: absolute; top: -100px;\"><\/div>\n<\/h4>\n<p>\u5728\u6253\u5f00 INI \u76d1\u63a7\u53c2\u6570 AUTO_STAT_OBJ\uff08\u4e3a 1 \u6216 2\uff09\u7684\u524d\u63d0\u4e0b\uff0c\u53ef\u4f7f\u7528 SP_CREATE_AUTO_STAT_TRIGGER \u8fc7\u7a0b\u5bf9\u8868\u7684\u76d1\u63a7\u4fe1\u606f\u8fdb\u884c\u81ea\u52a8\u6536\u96c6\u3002<\/p>\n<p>\u4e0b\u9762\u8be6\u7ec6\u4ecb\u7ecd\u4f7f\u7528 SP_CREATE_AUTO_STAT_TRIGGER \u8fc7\u7a0b\u81ea\u52a8\u6536\u96c6\u7528\u6237\u8868\u7684\u7edf\u8ba1\u4fe1\u606f\u7684\u5b8c\u6574\u8fc7\u7a0b\u3002<\/p>\n<p>\u7b2c\u4e00\u6b65\uff0c\u6253\u5f00\u76d1\u63a7\u3002<\/p>\n<p>\u8bbe\u7f6e INI \u53c2\u6570 AUTO_STAT_OBJ \u4e3a 1 \u6216 2\u30021\uff1a\u5bf9\u6240\u6709\u8868\u8fdb\u884c\u76d1\u63a7\uff1b2\uff1a\u53ea\u5bf9\u7528\u6237\u901a\u8fc7 DBMS_STATS.SET_TABLE_PREFS \u8bbe\u7f6e\u8fc7 STALE_PERCENT \u5c5e\u6027\u7684\u8868\u5bf9\u8c61\u8fdb\u884c\u76d1\u63a7\u3002\u5982\u679c AUTO_STAT_OBJ=2\uff0c\u9700\u8fdb\u4e00\u6b65\u4f7f\u7528 DBMS_STATS.SET_TABLE_PREFS \u8bbe\u7f6e STALE_PERCENT \u5c5e\u6027\u3002<\/p>\n<pre><a class=\"btn-copy\" data-clipboard-target=\"\" style=\"text-align: center; float: right; margin-left: -64px; width: 64px; color: rgb(148, 163, 234); cursor: pointer; text-decoration: none; font-size: 13px; font-family: inherit; padding: 0px 0.3rem; position: relative; background: rgb(244, 244, 244); z-index: 9;\"><span>Copy<\/span><\/a><code class=\"language-plaintext hljs\" style=\"background: rgb(244, 244, 244);\">\/\/\u7528AUTO_STAT_OBJ=1\u6253\u5f00\u5bf9T\u8868\u7684\u76d1\u63a7\u3002\nCREATE TABLE T(A INT);\nSP_SET_PARA_VALUE(1,'AUTO_STAT_OBJ',1);\n\n\/\/\u7528AUTO_STAT_OBJ=2\u6253\u5f00\u5bf9T\u8868\u7684\u76d1\u63a7\u3002\nCREATE TABLE T(A INT);\nSP_SET_PARA_VALUE(1,'AUTO_STAT_OBJ',2);\nDBMS_STATS.SET_TABLE_PREFS('SYSDBA','T','STALE_PERCENT',15);\/\/\u5bf9\u4fee\u6539\u884c\u6570\u5360\u603b\u884c\u6570\u7684\u6bd4\u8fbe\u5230STALE_PERCENT\u8981\u6c42\u7684\u5bf9\u8c61\u548c\u603b\u884c\u6570\u4e3a0\u7684\u5bf9\u8c61\u6536\u96c6\u7edf\u8ba1\u4fe1\u606f\n<\/code><\/pre>\n<p>\u4e0b\u9762\u4ee5 AUTO_STAT_OBJ=2 \u4e3a\u4f8b\u3002<\/p>\n<p>\u7b2c\u4e8c\u6b65\uff0c\u6267\u884c\u7edf\u8ba1\u4fe1\u606f\u6536\u96c6\u64cd\u4f5c\u3002\u81ea\u52a8\u6536\u96c6\u7edf\u8ba1\u4fe1\u606f\u4f7f\u7528 SP_CREATE_AUTO_STAT_TRIGGER \u8bbe\u7f6e\u89e6\u53d1\u5668\u3002<\/p>\n<pre><a class=\"btn-copy\" data-clipboard-target=\"\" style=\"text-align: center; float: right; margin-left: -64px; width: 64px; color: rgb(148, 163, 234); cursor: pointer; text-decoration: none; font-size: 13px; font-family: inherit; padding: 0px 0.3rem; position: relative; background: rgb(244, 244, 244); z-index: 9;\"><span>Copy<\/span><\/a><code class=\"language-plaintext hljs\" style=\"background: rgb(244, 244, 244);\">SP_CREATE_AUTO_STAT_TRIGGER(1, 1, 1, 1,'11:20', '2021\/1\/11',0,1);\n<\/code><\/pre>\n<p>\u7b2c\u4e09\u6b65\uff0c\u5bf9\u7528\u6237\u8868 T \u8fdb\u884c\u589e\u5220\u6539\u64cd\u4f5c\u3002<\/p>\n<pre><a class=\"btn-copy\" data-clipboard-target=\"\" style=\"text-align: center; float: right; margin-left: -64px; width: 64px; color: rgb(148, 163, 234); cursor: pointer; text-decoration: none; font-size: 13px; font-family: inherit; padding: 0px 0.3rem; position: relative; background: rgb(244, 244, 244); z-index: 9;\"><span>Copy<\/span><\/a><code class=\"language-plaintext hljs\" style=\"background: rgb(244, 244, 244);\">insert into t select level connect by level&lt;=20;\n\ncommit;\n<\/code><\/pre>\n<p>\u7b2c\u56db\u6b65\uff0c\u901a\u8fc7\u7cfb\u7edf\u8868 SYSSTATTABLEIDU \u548c\u52a8\u6001\u89c6\u56fe V$AUTO_STAT_TABLE_IDU \u67e5\u770b\u76d1\u63a7\u4fe1\u606f\uff0c\u901a\u8fc7\u7cfb\u7edf\u8868 SYSSTATS \u67e5\u770b\u7edf\u8ba1\u4fe1\u606f\u3002<\/p>\n<p>\u53ea\u6709\u6253\u5f00\u76d1\u63a7\uff08\u8bbe\u7f6e AUTO_STAT_OBJ \u4e3a 1 \u6216 2\uff09\u540e\u5e76\u6267\u884c\u7edf\u8ba1\u4fe1\u606f\u6536\u96c6\u64cd\u4f5c\u4e4b\u540e\u624d\u80fd\u67e5\u770b\u5230 SYSSTATTABLEIDU \u548c SYSSTATS \u7684\u53d8\u5316\u3002SYSSTATTABLEIDU \u4e3a AUTO_STAT_OBJ \u7b49\u4e8e 1 \u6216 2 \u65f6\u5bf9\u4e0a\u4e00\u6b21\u7684\u7edf\u8ba1\u4fe1\u606f\u7684\u76d1\u63a7\u3002V$AUTO_STAT_TABLE_IDU \u4e3a AUTO_STAT_OBJ \u7b49\u4e8e 1 \u65f6\u7684\u7edf\u8ba1\u4fe1\u606f\u5b9e\u65f6\u76d1\u63a7\uff0c\u4e0d\u9700\u8981\u6267\u884c\u6536\u96c6\u7edf\u8ba1\u4fe1\u606f\u64cd\u4f5c\u4e5f\u80fd\u67e5\u770b\u3002<\/p>\n<p>\u672c\u4f8b\u4e2d AUTO_STAT_OBJ=2\u3002\u67e5\u770b\u76d1\u63a7\u4fe1\u606f\uff1a<\/p>\n<pre><a class=\"btn-copy\" data-clipboard-target=\"\" style=\"text-align: center; float: right; margin-left: -64px; width: 64px; color: rgb(148, 163, 234); cursor: pointer; text-decoration: none; font-size: 13px; font-family: inherit; padding: 0px 0.3rem; position: relative; background: rgb(244, 244, 244); z-index: 9;\"><span>Copy<\/span><\/a><code class=\"language-plaintext hljs\" style=\"background: rgb(244, 244, 244);\">\/\/\u5728\u89e6\u53d1\u5668\u89e6\u53d1\u4e4b\u540e\u67e5\u770b\nSQL&gt; SELECT * FROM SYSSTATTABLEIDU;\n\n\u884c\u53f7       ID          TOTAL_ROWS           INSERT_ROWS          DELETE_ROWS          UPDATE_ROWS\n---------- ----------- -------------------- -------------------- -------------------- --------------------\n           LAST_STAT_DT               MONITOR_FLAG RSVD1      TRUNCATED\n           -------------------------- ------------ ---------- -----------\n1          1074        20                   0                    0                    0\n           2022-01-11 14:37:02.000000 2            NULL       0\n<\/code><\/pre>\n<p>\u67e5\u770b\u7edf\u8ba1\u4fe1\u606f\uff1a<\/p>\n<pre><a class=\"btn-copy\" data-clipboard-target=\"\" style=\"text-align: center; float: right; margin-left: -64px; width: 64px; color: rgb(148, 163, 234); cursor: pointer; text-decoration: none; font-size: 13px; font-family: inherit; padding: 0px 0.3rem; position: relative; background: rgb(244, 244, 244); z-index: 9;\"><span>Copy<\/span><\/a><code class=\"language-plaintext hljs\" style=\"background: rgb(244, 244, 244);\">SQL&gt; SELECT * FROM SYSSTATS WHERE ID=1074;\n\n\u884c\u53f7       ID          COLID       T_FLAG T_TOTAL              N_SAMPLE             N_DISTINCT\n---------- ----------- ----------- ------ -------------------- -------------------- --------------------\n           N_NULL               V_MIN      V_MAX      BLEVEL      N_LEAF_PAGES         N_LEAF_USED_PAGES\n           -------------------- ---------- ---------- ----------- -------------------- --------------------\n           CLUSTER_FACTOR N_BUCKETS\n           -------------- -----------\n           DATA\n           -----------------------------------------------------------------------------------------------------------\n           COL_AVG_LEN LAST_GATHERED              INFO1      INFO2\n           ----------- -------------------------- ---------- ----------\n1          1074        -1          T      20                   0                    0\n           0                    NULL       NULL       0           1                    1\n           0              0\n           0X0000FFFF00000700\n           -1          2022-01-11 14:37:02.279000 NULL       NULL\n\n\u884c\u53f7       ID          COLID       T_FLAG T_TOTAL              N_SAMPLE             N_DISTINCT\n---------- ----------- ----------- ------ -------------------- -------------------- --------------------\n           N_NULL               V_MIN      V_MAX      BLEVEL      N_LEAF_PAGES         N_LEAF_USED_PAGES\n           -------------------- ---------- ---------- ----------- -------------------- --------------------\n           CLUSTER_FACTOR N_BUCKETS\n           -------------- -----------\n           DATA\n           -----------------------------------------------------------------------------------------------------------\n           COL_AVG_LEN LAST_GATHERED              INFO1      INFO2\n           ----------- -------------------------- ---------- ----------\n2          1074        0           C      20                   20                   20\n           0                    0X01000000 0X14000000 0           1                    1\n           0              20\n           0X1400010008000700010000000100000001000000020000000100000003000000010000000400000001000000050000000100000006000000010000000700000001000000080000000100000009000000010000000A000000010000000B000000010000000C000000010000000D000000010000000E000000010000000F00000001000000100000000100000011000000010000001200000001000000130000000100000014000000\n           4           2022-01-11 14:37:02.307000 NULL       NULL\n\n<\/code><\/pre>\n<p>\u7b2c\u4e94\u6b65\uff0c\u76d1\u63a7\u7edf\u8ba1\u4fe1\u606f\u6536\u96c6\u8fc7\u7a0b\u3002\u63a5\u7740\u4e0a\u4e00\u6b65\u7684\u4f8b\u5b50\uff0c\u5c55\u793a\u76d1\u63a7\u7684\u5b8c\u6574\u8fc7\u7a0b\u3002<\/p>\n<p>\u9996\u5148\uff0c\u521b\u5efa\u4e00\u4e2a\u7528\u6237\u8868 AUTO_STAT_INFO\uff0c\u7528\u4ee5\u4fdd\u5b58\u81ea\u52a8\u6536\u96c6\u8fc7\u7a0b\u7684\u76f8\u5173\u4fe1\u606f\u3002<\/p>\n<pre><a class=\"btn-copy\" data-clipboard-target=\"\" style=\"text-align: center; float: right; margin-left: -64px; width: 64px; color: rgb(148, 163, 234); cursor: pointer; text-decoration: none; font-size: 13px; font-family: inherit; padding: 0px 0.3rem; position: relative; background: rgb(244, 244, 244); z-index: 9;\"><span>Copy<\/span><\/a><code class=\"language-plaintext hljs\" style=\"background: rgb(244, 244, 244);\">create table AUTO_STAT_INFO(\n\ntask_id INT,\n\ntotal_stat INT,\n\ntable_id INT, \n\nsch_name varchar(24), \n\ntable_name varchar(24),\n\ncurr_gath_tab_id INT, \n\ncurr_gath_sch_name varchar(24), \n\ncurr_gath_tab_name varchar(24),\n\nsuccess_stat INT,\n\nfail_stat INT,\n\ntask_start_time DATETIME, \n\ntask_end_time DATETIME,\n\ngather_tbl_start_time DATETIME,\n\ngather_tbl_end_time DATETIME\n\n);\n<\/code><\/pre>\n<p>\u5176\u6b21\uff0c\u521b\u5efa\u8fc7\u7a0b SYSDBA.GET_AUTO_STAT_INFO_FUNC\uff0c\u63a5\u6536\u670d\u52a1\u5668\u5728\u81ea\u52a8\u6536\u96c6\u7edf\u8ba1\u4fe1\u606f\u65f6\u7684\u8fc7\u7a0b\u4fe1\u606f\u3002\u5e76\u5728\u6a21\u5757\u4f53\u7f16\u5199\u7528\u6237\u4ee3\u7801\uff0c\u5c06\u8fc7\u7a0b\u6536\u96c6\u7684\u7edf\u8ba1\u4fe1\u606f\u5199\u5165 AUTO_STAT_INFO \u4e2d\u3002<\/p>\n<pre><a class=\"btn-copy\" data-clipboard-target=\"\" style=\"text-align: center; float: right; margin-left: -64px; width: 64px; color: rgb(148, 163, 234); cursor: pointer; text-decoration: none; font-size: 13px; font-family: inherit; padding: 0px 0.3rem; position: relative; background: rgb(244, 244, 244); z-index: 9;\"><span>Copy<\/span><\/a><code class=\"language-plaintext hljs\" style=\"background: rgb(244, 244, 244);\">CREATE OR REPLACE PROCEDURE  SYSDBA.GET_AUTO_STAT_INFO_FUNC(task_id INT,total_stat INT,table_id INT, sch_name varchar(24), table_name varchar(24),curr_gath_tab_id INT, curr_gath_sch_name varchar(24), curr_gath_tab_name varchar(24),success_stat INT,fail_stat INT,task_start_time DATETIME, task_end_time DATETIME,gather_tbl_start_time DATETIME,gather_tbl_end_time DATETIME) as\nBEGIN\n\/\/\u4e0b\u9762\u662f\u7528\u6237\u81ea\u5b9a\u4e49\u7684\u4ee3\u7801\uff0c\u5c06SYSDBA.GET_AUTO_STAT_INFO_FUNC\u8fc7\u7a0b\u7684\u4fe1\u606f\u63d2\u5165\u5230\u7528\u6237\u8868AUTO_STAT_INFO \u4e2d\n    INSERT INTO AUTO_STAT_INFO VALUES(task_id,total_stat,table_id, sch_name,table_name,curr_gath_tab_id, curr_gath_sch_name, curr_gath_tab_name,success_stat ,fail_stat,task_start_time,task_end_time,gather_tbl_start_time,gather_tbl_end_time);\n    commit;\nEXCEPTION\n    WHEN OTHERS THEN\n        NULL;\nEND;\n\/\n<\/code><\/pre>\n<p>\u6700\u540e\uff0c\u89e3\u8bfb\u8868 AUTO_STAT_INFO\uff0c\u4ecb\u7ecd\u4e00\u6b21\u81ea\u52a8\u6536\u96c6\u7edf\u8ba1\u4fe1\u606f\u4efb\u52a1\u7684\u76f8\u5173\u8fc7\u7a0b\u4fe1\u606f\u3002\u5982\u679c SP_CREATE_AUTO_STAT_TRIGGER \u89e6\u53d1\u4e00\u6b21\u81ea\u52a8\u6536\u96c6\u7edf\u8ba1\u4fe1\u606f\uff0c\u5728\u4efb\u52a1\u5f00\u59cb\u65f6\uff0c\u4f1a\u5148\u8bb0\u5f55\u5f53\u524d\u4efb\u52a1\u7684\u5f00\u59cb\u65f6\u95f4\uff0c\u5f53\u524d\u4efb\u52a1\u7684\u5f85\u6536\u96c6\u8868\u7684\u603b\u4e2a\u6570\uff0c\u4ee5\u53ca\u63a5\u4e0b\u6765\u5f85\u6536\u96c6\u7684\u8868\u7684 id\u3002\u4e4b\u540e\u6bcf\u6536\u96c6\u5b8c\u6210\u4e00\u4e2a\u8868\u7684\u7edf\u8ba1\u4fe1\u606f\uff0c\u5c31\u4f1a\u8bb0\u5f55\u8be5\u8868 table \u7684 id \u53ca\u6536\u96c6\u8be5\u8868\u7684\u5f00\u59cb\u548c\u7ed3\u675f\u65f6\u95f4\uff0c\u548c\u622a\u81f3\u76ee\u524d\u6536\u96c6\u6210\u529f\u5931\u8d25\u7684\u8868\u4e2a\u6570\u60c5\u51b5\uff0c\u4ee5\u53ca\u63a5\u4e0b\u6765\u5f85\u6536\u96c6\u7684\u8868\u7684 id\u3002\u5176\u4e2d\u201c\u63a5\u4e0b\u6765\u5f85\u6536\u96c6\u7684\u8868\u7684 id\u201d\u5373 current_gather_tab_id\uff0c\u4e3a\u5f53\u524d\u670d\u52a1\u5668\u6b63\u5728\u6536\u96c6\u7684\u8868 id\u3002<\/p>\n<h4 id=\"22-5-3-2-\u624b\u52a8\u6536\u96c6\" class=\"article-heading\" style=\"position: relative;\">22.5.3.2 \u624b\u52a8\u6536\u96c6<a class=\"article-anchor\" href=\"#22.5.3.2 \u624b\u52a8\u6536\u96c6\" aria-hidden=\"true\"><\/a><\/p>\n<div id=\"22.5.3.2 \u624b\u52a8\u6536\u96c6\" style=\"position: absolute; top: -100px;\"><\/div>\n<\/h4>\n<p>\u4f8b \u4f7f\u7528 DBMS_STATS \u5305\u4e2d GATHER_TABLE_STATS \u65b9\u6cd5\u624b\u52a8\u6536\u96c6\u7528\u6237\u8868\u7684\u7edf\u8ba1\u4fe1\u606f\u7684\u5b8c\u6574\u8fc7\u7a0b\u3002<\/p>\n<p>\u4f7f\u7528\u5305\u5185\u7684\u8fc7\u7a0b\u548c\u51fd\u6570\u4e4b\u524d\uff0c\u5982\u679c\u8fd8\u672a\u521b\u5efa\u8fc7\u7cfb\u7edf\u5305\u3002\u8bf7\u5148\u8c03\u7528\u7cfb\u7edf\u8fc7\u7a0b\u521b\u5efa\u7cfb\u7edf\u5305\u3002<\/p>\n<pre><a class=\"btn-copy\" data-clipboard-target=\"\" style=\"text-align: center; float: right; margin-left: -64px; width: 64px; color: rgb(148, 163, 234); cursor: pointer; text-decoration: none; font-size: 13px; font-family: inherit; padding: 0px 0.3rem; position: relative; background: rgb(244, 244, 244); z-index: 9;\"><span>Copy<\/span><\/a><code class=\"language-plaintext hljs\" style=\"background: rgb(244, 244, 244);\">SP_CREATE_SYSTEM_PACKAGES (1,'DBMS_STATS');\nSET SERVEROUTPUT ON; \/\/PRINT\u9700\u8981\u8bbe\u7f6e\u8fd9\u6761\u8bed\u53e5\uff0c\u624d\u80fd\u6253\u5370\u51fa\u6d88\u606f\n<\/code><\/pre>\n<p>\u6536\u96c6\u6a21\u5f0f PERSON \u4e0b\u8868 ADDRESS \u7684\u7edf\u8ba1\u4fe1\u606f\uff0c\u5e76\u6253\u5370\u6536\u96c6\u7684\u8868\u4fe1\u606f\u3002<\/p>\n<pre><a class=\"btn-copy\" data-clipboard-target=\"\" style=\"text-align: center; float: right; margin-left: -64px; width: 64px; color: rgb(148, 163, 234); cursor: pointer; text-decoration: none; font-size: 13px; font-family: inherit; padding: 0px 0.3rem; position: relative; background: rgb(244, 244, 244); z-index: 9;\"><span>Copy<\/span><\/a><code class=\"language-plaintext hljs\" style=\"background: rgb(244, 244, 244);\">BEGIN\n    DECLARE \n     OBJTAB DBMS_STATS.OBJECTTAB;\n     OBJ_FILTER_LIST DBMS_STATS.OBJECTTAB;\n    BEGIN\n        OBJ_FILTER_LIST(0).OWNNAME = 'PERSON';\n        OBJ_FILTER_LIST(0).OBJTYPE = 'TABLE';\n        OBJ_FILTER_LIST(0).OBJNAME = 'ADDRESS';\n    DBMS_STATS.GATHER_SCHEMA_STATS(\n       'PERSON', \n        1.0,\n        FALSE,\n        'FOR ALL COLUMNS SIZE AUTO',\n        1,\n        'AUTO',\n        TRUE,\n        NULL,\n        NULL,\n        'GATHER',\n        OBJTAB,\n        NULL,\n        TRUE,\n        TRUE,\n        OBJ_FILTER_LIST\n    );\n    PRINT OBJTAB.COUNT;\n        FOR I IN 0..OBJTAB.COUNT-1 LOOP\n            PRINT OBJTAB(I).OWNNAME;\n            PRINT OBJTAB(I).OBJTYPE;\n            PRINT OBJTAB(I).OBJNAME;\n            PRINT OBJTAB(I).PARTNAME;\n            PRINT OBJTAB(I).SUBPARTNAME;\n            PRINT '-------- ';\n         END LOOP;\n    END;\nEND;\n\/\n<\/code><\/pre>\n<p>\u6253\u5370\u7ed3\u679c\uff1a<\/p>\n<pre><a class=\"btn-copy\" data-clipboard-target=\"\" style=\"text-align: center; float: right; margin-left: -64px; width: 64px; color: rgb(148, 163, 234); cursor: pointer; text-decoration: none; font-size: 13px; font-family: inherit; padding: 0px 0.3rem; position: relative; background: rgb(244, 244, 244); z-index: 9;\"><span>Copy<\/span><\/a><code class=\"language-plaintext hljs\" style=\"background: rgb(244, 244, 244);\">1\n\nPERSON\n\nTABLE\n\nADDRESS\n\nNULL\n\nNULL\n<\/code><\/pre>\n<h2 id=\"22-6-\u6267\u884c\u8ba1\u5212\" class=\"article-heading\" style=\"position: relative;\">22.6 \u6267\u884c\u8ba1\u5212<a class=\"article-anchor\" href=\"#22.6 \u6267\u884c\u8ba1\u5212\" aria-hidden=\"true\"><\/a><\/p>\n<div id=\"22.6 \u6267\u884c\u8ba1\u5212\" style=\"position: absolute; top: -100px;\"><\/div>\n<\/h2>\n<p>\u6267\u884c\u8ba1\u5212\u662f SQL \u8bed\u53e5\u7684\u6267\u884c\u65b9\u5f0f\uff0c\u7531\u67e5\u8be2\u4f18\u5316\u5668\u4e3a\u8bed\u53e5\u8bbe\u8ba1\u7684\u6267\u884c\u65b9\u5f0f\uff0c\u4ea4\u7ed9\u6267\u884c\u5668\u53bb\u6267\u884c\u3002\u5728 SQL \u547d\u4ee4\u884c\u4f7f\u7528 EXPLAIN \u53ef\u4ee5\u6253\u5370\u51fa\u8bed\u53e5\u7684\u6267\u884c\u8ba1\u5212\u3002<\/p>\n<p>\u4f8b\u5982\uff1a<\/p>\n<p>\u5efa\u8868\u548c\u5efa\u7d22\u5f15\u8bed\u53e5\uff1a<\/p>\n<pre><a class=\"btn-copy\" data-clipboard-target=\"\" style=\"text-align: center; float: right; margin-left: -64px; width: 64px; color: rgb(148, 163, 234); cursor: pointer; text-decoration: none; font-size: 13px; font-family: inherit; padding: 0px 0.3rem; position: relative; background: rgb(244, 244, 244); z-index: 9;\"><span>Copy<\/span><\/a><code class=\"language-plaintext hljs\" style=\"background: rgb(244, 244, 244);\">    CREATE TABLE T1(C1 INT,C2 CHAR);\n    CREATE TABLE T2(D1 INT,D2 CHAR);\n    CREATE  INDEX  IDX_T1_C1  ON  T1(C1);\n    INSERT INTO T1 VALUES(1,'A');\n    INSERT INTO T1 VALUES(2,'B');\n    INSERT INTO T1 VALUES(3,'C');\n    INSERT INTO T1 VALUES(4,'D');\n    INSERT INTO T2 VALUES(1,'A');\n    INSERT INTO T2 VALUES(2,'B');\n    INSERT INTO T2 VALUES(5,'C');\n    INSERT INTO T2 VALUES(6,'D');\n<\/code><\/pre>\n<p>\u6253\u5370\u6267\u884c\u8ba1\u5212\uff1a<\/p>\n<pre><a class=\"btn-copy\" data-clipboard-target=\"\" style=\"text-align: center; float: right; margin-left: -64px; width: 64px; color: rgb(148, 163, 234); cursor: pointer; text-decoration: none; font-size: 13px; font-family: inherit; padding: 0px 0.3rem; position: relative; background: rgb(244, 244, 244); z-index: 9;\"><span>Copy<\/span><\/a><code class=\"language-plaintext hljs\" style=\"background: rgb(244, 244, 244);\">  EXPLAIN SELECT A.C1+1,B.D2 FROM T1 A, T2 B WHERE A.C1 = B.D1;\n<\/code><\/pre>\n<p>\u6267\u884c\u8ba1\u5212\u5982\u4e0b\uff1a<\/p>\n<pre><a class=\"btn-copy\" data-clipboard-target=\"\" style=\"text-align: center; float: right; margin-left: -64px; width: 64px; color: rgb(148, 163, 234); cursor: pointer; text-decoration: none; font-size: 13px; font-family: inherit; padding: 0px 0.3rem; position: relative; background: rgb(244, 244, 244); z-index: 9;\"><span>Copy<\/span><\/a><code class=\"language-plaintext hljs\" style=\"background: rgb(244, 244, 244);\">    1   ##NSET2: [0, 16, 9] \n    2     ##PRJT2: [0, 16, 9]; EXP_NUM(2), IS_ATOM(FALSE) \n    3       ##NEST LOOP INDEX JOIN2: [0, 16, 9] \n    4         ##CSCN2: [0, 4, 5]; INDEX33555535(B)\n    5         ##SSEK2: [0, 4, 0]; SCAN_TYPE(ASC), IDX_T1_C1 (A), SCAN_RANGE[T2.D1,T2.D1]\n<\/code><\/pre>\n<p>\u8fd9\u4e2a\u6267\u884c\u8ba1\u5212\u770b\u8d77\u6765\u5c31\u50cf\u4e00\u68f5\u6811\uff0c\u6267\u884c\u8fc7\u7a0b\u4e3a\uff1a\u63a7\u5236\u6d41\u4ece\u4e0a\u5411\u4e0b\u4f20\u9012\uff0c\u6570\u636e\u6d41\u4ece\u4e0b\u5411\u4e0a\u4f20\u9012\u3002\u5176\u4e2d\uff0c\u7c7b\u4f3c[0, 16, 9]\u8fd9\u6837\u7684\u4e09\u4e2a\u6570\u5b57\uff0c\u5206\u522b\u8868\u793a\u4f30\u7b97\u7684\u64cd\u4f5c\u7b26\u4ee3\u4ef7\u3001\u5904\u7406\u7684\u8bb0\u5f55\u884c\u6570\u548c\u6bcf\u884c\u8bb0\u5f55\u7684\u5b57\u8282\u6570\u3002\u540c\u4e00\u5c42\u6b21\u4e2d\u7684\u64cd\u4f5c\u7b26\uff0c\u5982\u672c\u4f8b\u4e2d\u7684 CSCN2 \u548c SSEK2\uff0c\u7531\u7236\u8282\u70b9 NEST LOOP INDEX JOIN2 \u63a7\u5236\u5b83\u4eec\u7684\u6267\u884c\u987a\u5e8f\u3002<\/p>\n<p>\u8be5\u8ba1\u5212\u7684\u5927\u81f4\u6267\u884c\u6d41\u7a0b\u5982\u4e0b\uff1a<\/p>\n<ol>\n<li>CSCN2: \u626b\u63cf T2 \u8868\u7684\u805a\u96c6\u7d22\u5f15\uff0c\u6570\u636e\u4f20\u9012\u7ed9\u7236\u8282\u70b9\u7d22\u5f15\u8fde\u63a5\uff1b<\/li>\n<li>NEST LOOP INDEX JOIN2: \u5f53\u5de6\u5b69\u5b50\u6709\u6570\u636e\u8fd4\u56de\u65f6\u53d6\u53f3\u4fa7\u6570\u636e\uff1b<\/li>\n<li>SSEK2: \u5229\u7528 T2 \u8868\u5f53\u524d\u7684 D1 \u503c\u4f5c\u4e3a\u4e8c\u7ea7\u7d22\u5f15 IDX_T1_C1 \u5b9a\u4f4d\u67e5\u627e\u7684 KEY\uff0c\u8fd4\u56de\u7ed3\u679c\u7ed9\u7236\u8282\u70b9\uff1b<\/li>\n<li>NEST LOOP INDEX JOIN2: \u5982\u679c\u53f3\u5b69\u5b50\u6709\u6570\u636e\u5219\u5c06\u7ed3\u679c\u4f20\u9012\u7ed9\u7236\u8282\u70b9 PRJT2\uff0c\u5426\u5219\u7ee7\u7eed\u53d6\u5de6\u5b69\u5b50\u7684\u4e0b\u4e00\u6761\u8bb0\u5f55\uff1b<\/li>\n<li>PRJT2: \u8fdb\u884c\u8868\u8fbe\u5f0f\u8ba1\u7b97 C1+1, D2\uff1b<\/li>\n<li>NSET2: \u8f93\u51fa\u6700\u540e\u7ed3\u679c\uff1b<\/li>\n<li>\u91cd\u590d\u8fc7\u7a0b 1) ~ 4)\u76f4\u81f3\u5de6\u4fa7 CSCN2 \u6570\u636e\u5168\u90e8\u53d6\u5b8c\u3002<\/li>\n<\/ol>\n<p>\u7528\u6237\u5982\u679c\u60f3\u4e86\u89e3\u66f4\u591a\u5173\u4e8e\u64cd\u4f5c\u7b26\u7684\u77e5\u8bc6\uff0c\u8bf7\u67e5\u770b\u52a8\u6001\u89c6\u56fe V$SQL_NODE_NAME\uff0c\u624b\u518c\u7684<a href=\"#\u9644\u5f554\u2014\u2014\u6267\u884c\u8ba1\u5212\u64cd\u4f5c\u7b26\">\u9644\u5f55 4 \u6267\u884c\u8ba1\u5212\u64cd\u4f5c\u7b26<\/a>\u7ed9\u51fa\u4e86\u5e38\u7528\u64cd\u4f5c\u7b26\u7684\u8bf4\u660e\u3002<\/p>\n<h3 id=\"22-6-1-\u81ea\u9002\u5e94\u8ba1\u5212\" class=\"article-heading\" style=\"position: relative;\">22.6.1 \u81ea\u9002\u5e94\u8ba1\u5212<a class=\"article-anchor\" href=\"#22.6.1 \u81ea\u9002\u5e94\u8ba1\u5212\" aria-hidden=\"true\"><\/a><\/p>\n<div id=\"22.6.1 \u81ea\u9002\u5e94\u8ba1\u5212\" style=\"position: absolute; top: -100px;\"><\/div>\n<\/h3>\n<p>\u5728 DM \u4f18\u5316\u5668\u8fdb\u884c\u4ee3\u4ef7\u4f30\u7b97\u65f6\uff0c\u5982\u679c\u5b50\u8282\u70b9\u662f\u4e00\u4e2a\u590d\u6742\u67e5\u8be2\uff0c\u53ef\u80fd\u4f7f\u5f97\u5bf9\u4e8e\u5b50\u8282\u70b9\u7684\u4ee3\u4ef7\u4f30\u7b97\u4e0d\u51c6\u786e\uff0c\u5bfc\u81f4\u6700\u7ec8\u9009\u62e9\u7684\u8ba1\u5212\u5728\u6267\u884c\u65f6\u5e76\u975e\u6700\u4f18\u8ba1\u5212\u3002\u56e0\u6b64\uff0cDM \u5f15\u5165\u4e86\u81ea\u9002\u5e94\u8ba1\u5212\u673a\u5236\u3002<\/p>\n<p>\u5c06 INI \u53c2\u6570 OPTIMIZER_MODE \u548c ADAPTIVE_NPLN_FLAG \u90fd\u7f6e\u4e3a 1\uff0c\u542f\u7528\u81ea\u9002\u5e94\u8ba1\u5212\u673a\u5236\u3002\u6b64\u65f6\uff0c\u4f18\u5316\u5668\u4f1a\u81ea\u52a8\u5224\u65ad\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u590d\u6742\u67e5\u8be2\u7684\u5b50\u8282\u70b9\u53ef\u80fd\u5bfc\u81f4\u4ee3\u4ef7\u4f30\u7b97\u4e0d\u51c6\u786e\uff0c\u5219\u4f1a\u4e3a\u8be5\u8282\u70b9\u751f\u6210\u4e00\u4e2a\u5907\u7528\u8ba1\u5212\u8282\u70b9\u3002\u5728\u5b9e\u9645\u6267\u884c\u5230\u8be5\u8282\u70b9\u65f6\uff0c\u6839\u636e\u51c6\u786e\u7684\u4ee3\u4ef7\u4fe1\u606f\u786e\u5b9a\u662f\u5426\u9700\u8981\u91c7\u7528\u5907\u7528\u8ba1\u5212\u3002<\/p>\n<p>\u4f8b\u5982\uff1a<\/p>\n<p>\u5efa\u8868\u3001\u63d2\u5165\u6570\u636e\u5e76\u5efa\u7d22\u5f15\uff1a<\/p>\n<pre><a class=\"btn-copy\" data-clipboard-target=\"\" style=\"text-align: center; float: right; margin-left: -64px; width: 64px; color: rgb(148, 163, 234); cursor: pointer; text-decoration: none; font-size: 13px; font-family: inherit; padding: 0px 0.3rem; position: relative; background: rgb(244, 244, 244); z-index: 9;\"><span>Copy<\/span><\/a><code class=\"language-plaintext hljs\" style=\"background: rgb(244, 244, 244);\">    DROP TABLE T1;\n    DROP TABLE T2;\n\n    CREATE TABLE T1(C1 INT,C2 INT);\n    CREATE TABLE T2(D1 INT,D2 INT);\n\n    INSERT INTO T1 VALUES(1,1);\n    INSERT INTO T1 VALUES(1,2);\n    INSERT INTO T2 VALUES(1,1);\n    INSERT INTO T2 VALUES(2,1);\n    INSERT INTO T2 VALUES(3,1);\n    INSERT INTO T2 VALUES(4,1);\n    INSERT INTO T2 VALUES(5,1);\n    COMMIT;\n\n    CREATE INDEX IND1 ON T1(C2);\n<\/code><\/pre>\n<p>\u6253\u5370\u6267\u884c\u8ba1\u5212\uff1a<\/p>\n<pre><a class=\"btn-copy\" data-clipboard-target=\"\" style=\"text-align: center; float: right; margin-left: -64px; width: 64px; color: rgb(148, 163, 234); cursor: pointer; text-decoration: none; font-size: 13px; font-family: inherit; padding: 0px 0.3rem; position: relative; background: rgb(244, 244, 244); z-index: 9;\"><span>Copy<\/span><\/a><code class=\"language-plaintext hljs\" style=\"background: rgb(244, 244, 244);\">  EXPLAIN SELECT * FROM T1 ,T2 ,T1 T3 WHERE T2.D1= T3.C1 AND T1.C2=T2.D2;\n<\/code><\/pre>\n<p>\u6267\u884c\u8ba1\u5212\u5982\u4e0b\uff1a<\/p>\n<pre><a class=\"btn-copy\" data-clipboard-target=\"\" style=\"text-align: center; float: right; margin-left: -64px; width: 64px; color: rgb(148, 163, 234); cursor: pointer; text-decoration: none; font-size: 13px; font-family: inherit; padding: 0px 0.3rem; position: relative; background: rgb(244, 244, 244); z-index: 9;\"><span>Copy<\/span><\/a><code class=\"language-plaintext hljs\" style=\"background: rgb(244, 244, 244);\">    1   ##NSET2: [1, 2, 24]\n    2     ##PRJT2: [1, 2, 24]; exp_num(6), is_atom(FALSE)\n    3       ##HASH2 INNER JOIN: [1, 0, 0];  KEY_NUM(1);\n    4         ##NEST LOOP INDEX JOIN2: [1, 2, 24]\n    5           ##ACTRL: [1, 2, 24];\n    6             ##HASH2 INNER JOIN: [0, 5, 16];  KEY_NUM(1);\n    7               ##CSCN2: [0, 2, 8]; INDEX33555445(T1 as T3)\n    8               ##CSCN2: [0, 5, 8]; INDEX33555446(T2)\n    9           ##BLKUP2: [0, 1, 0]; IND1(T1)\n    10            ##SSEK2: [0, 1, 0]; scan_type(ASC), IND1(T1), scan_range[T2.D2,T2.D2]\n    11        ##CSCN2: [0, 2, 8]; INDEX33555445(T1)\n<\/code><\/pre>\n<p>\u53ef\u4ee5\u770b\u5230\u6267\u884c\u8ba1\u5212\u4e2d\u6709\u4e00\u4e2a ACTRL \u64cd\u4f5c\u7b26\uff0c\u5b83\u8bf4\u660e\u4f18\u5316\u5668\u4e3a\u8fd9\u4e00\u6761 SQL \u8bed\u53e5\u751f\u6210\u4e86\u5907\u7528\u8ba1\u5212\u3002ACTRL \u662f\u63a7\u5236\u5907\u7528\u8ba1\u5212\u8f6c\u6362\u7684\u64cd\u4f5c\u7b26\uff0c\u5176\u4e0a\u9762\u4e00\u5c42 NEST LOOP INDEX JOIN2 \u4e3a\u9ed8\u8ba4\u7684\u4e3b\u8ba1\u5212\uff0c\u518d\u4e0a\u9762\u4e00\u5c42 HASH2 INNER JOIN \u5219\u4e3a\u5907\u7528\u8ba1\u5212\u3002ACTRL \u64cd\u4f5c\u7b26\u8ba1\u7b97\u4e0b\u5c42\u5b69\u5b50\u8282\u70b9\u7684\u4ee3\u4ef7\uff0c\u51b3\u5b9a\u91c7\u7528\u9ed8\u8ba4\u4e3b\u8ba1\u5212\u8fd8\u662f\u5907\u7528\u8ba1\u5212\u3002<\/p>\n<p>\u9700\u8981\u8bf4\u660e\u7684\u662f\uff0cMPP \u548c\u5e76\u884c\u67e5\u8be2\u4e0d\u652f\u6301\u81ea\u9002\u5e94\u8ba1\u5212\u3002<\/p>\n<h2 id=\"22-7-\u4f7f\u7528\u7d22\u5f15\" class=\"article-heading\" style=\"position: relative;\">22.7 \u4f7f\u7528\u7d22\u5f15<a class=\"article-anchor\" href=\"#22.7 \u4f7f\u7528\u7d22\u5f15\" aria-hidden=\"true\"><\/a><\/p>\n<div id=\"22.7 \u4f7f\u7528\u7d22\u5f15\" style=\"position: absolute; top: -100px;\"><\/div>\n<\/h2>\n<p>\u4e3a\u4e86\u63d0\u9ad8\u67e5\u8be2\u6548\u7387\uff0c\u7528\u6237\u4e00\u822c\u4f1a\u5728\u8868\u4e2d\u521b\u5efa\u7d22\u5f15\u3002\u67e5\u8be2\u4e2d\u7684\u6761\u4ef6\u5217\u4e3a\u7d22\u5f15\u5217\u65f6\uff0c\u5982\u679c\u7d22\u5f15\u626b\u63cf\u4ee3\u4ef7\u6700\u5c0f\uff0c\u4f18\u5316\u5668\u5c31\u4f1a\u91c7\u7528\u7d22\u5f15\u626b\u63cf\u3002\u7d22\u5f15\u626b\u63cf\u6709\u591a\u79cd\u65b9\u5f0f\uff0c\u4f8b\u5982\uff0c\u7d22\u5f15\u7b49\u503c\u67e5\u8be2\u3001\u7d22\u5f15\u8303\u56f4\u67e5\u8be2\u3002\u5982\u679c\u67e5\u8be2\u5217\u5c5e\u4e8e\u7d22\u5f15\u5217\u7684\u5b50\u96c6\uff0c\u5219\u901a\u8fc7\u7d22\u5f15\u626b\u63cf\u5c31\u53ef\u4ee5\u83b7\u5f97\u6570\u636e\uff0c\u5426\u5219\uff0c\u8fd8\u9700\u8981\u6839\u636e ROWID \u6216\u8005 PK \u5728\u805a\u96c6\u7d22\u5f15\u4e2d\u5b9a\u4f4d\u8bb0\u5f55\u3002<\/p>\n<p>\u5e38\u7528\u7684\u7d22\u5f15\u7c7b\u578b\u6709\u552f\u4e00\u7d22\u5f15\u3001\u7ec4\u5408\u7d22\u5f15\u3001\u51fd\u6570\u7d22\u5f15\u3002\u5404\u81ea\u6709\u4e0d\u540c\u7684\u4f7f\u7528\u573a\u666f\u3002<\/p>\n<ol>\n<li>\u6761\u4ef6\u5217\u5177\u6709 UNIQUE \u7ea6\u675f\uff0c\u5219\u53ef\u4ee5\u521b\u5efa\u552f\u4e00\u7d22\u5f15\uff0c\u51cf\u5c11\u7d22\u5f15\u626b\u63cf\u6b21\u6570\uff1b<\/li>\n<li>\u6761\u4ef6\u5217\u662f\u591a\u4e2a\u5217\uff0c\u800c\u4e14\u53ef\u4ee5\u8fc7\u6ee4\u6389\u5927\u90e8\u5206\u6570\u636e\uff0c\u53ef\u4ee5\u5728\u591a\u4e2a\u5217\u4e0a\u521b\u5efa\u7ec4\u5408\u7d22\u5f15\uff0c\u628a\u7b49\u503c\u6761\u4ef6\u5217\u4f5c\u4e3a\u7ec4\u5408\u7d22\u5f15\u7684\u9996\u5217\uff1b<\/li>\n<li>\u6761\u4ef6\u5217\u4f7f\u7528\u786e\u5b9a\u6027\u51fd\u6570(\u540c\u6837\u73af\u5883\u4e0b\u591a\u6b21\u6267\u884c\u5f97\u5230\u76f8\u540c\u7684\u7ed3\u679c)\uff0c\u53ef\u4ee5\u521b\u5efa\u51fd\u6570\u7d22\u5f15\uff0c\u4f1a\u628a\u51fd\u6570\u503c\u8fdb\u884c\u5b58\u50a8\uff0c\u4f7f\u7528\u65b9\u5f0f\u4e0e\u666e\u901a\u7d22\u5f15\u4e00\u6837\uff1b<\/li>\n<li>\u5728\u7a7a\u95f4\u6570\u636e\u5e94\u7528\u4e2d\uff0c\u53ef\u4ee5\u521b\u5efa\u7a7a\u95f4\u7d22\u5f15\u63d0\u9ad8\u7a7a\u95f4\u67e5\u8be2\u7684\u6548\u7387\u3002<\/li>\n<\/ol>\n<h2 id=\"22-8-\u5e76\u884c\u67e5\u8be2\" class=\"article-heading\" style=\"position: relative;\">22.8 \u5e76\u884c\u67e5\u8be2<a class=\"article-anchor\" href=\"#22.8 \u5e76\u884c\u67e5\u8be2\" aria-hidden=\"true\"><\/a><\/p>\n<div id=\"22.8 \u5e76\u884c\u67e5\u8be2\" style=\"position: absolute; top: -100px;\"><\/div>\n<\/h2>\n<p>\u5e76\u884c\u67e5\u8be2\uff08Parallel Query\uff0cPQ\uff09\u662f\u4e00\u79cd\u591a\u4e2a\u7ebf\u7a0b\u6216\u8fdb\u7a0b\u95f4\u534f\u4f5c\u3001\u5171\u540c\u5b8c\u6210 SQL \u8ba1\u5212\u7684\u4f18\u5316\u6280\u672f\u3002<\/p>\n<p>\u6839\u636e\u53c2\u4e0e\u6267\u884c\u7684 DM \u670d\u52a1\u5668\u5b9e\u4f8b\u4e2a\u6570\uff0c\u5e76\u884c\u67e5\u8be2\u53ef\u4ee5\u5212\u5206\u4e3a\u591a\u673a\u5e76\u884c\u67e5\u8be2\u548c\u5355\u673a\u5e76\u884c\u67e5\u8be2\u3002\u5355\u673a\u5e76\u884c\u67e5\u8be2\u4ec5\u5229\u7528\u4e86\u5355\u673a\u7684 CPU\u3001\u78c1\u76d8\u3001\u5185\u5b58\u7b49\u673a\u5668\u8d44\u6e90\uff0c\u56e0\u6b64\u53c8\u79f0\u4e3a\u672c\u5730\u5e76\u884c\u67e5\u8be2\u3002<\/p>\n<p>DM \u652f\u6301\u672c\u5730\u5e76\u884c\u548c\u591a\u673a\u5e76\u884c\uff0c\u5e76\u884c\u67e5\u8be2\u5177\u4f53\u5b9e\u73b0\u4e0a\u91c7\u7528\u5bf9\u79f0\u5e76\u884c\u6280\u672f\uff0c\u5373\u6bcf\u4e00\u4e2a\u6267\u884c\u8005\uff08\u8fdb\u7a0b\u6216\u7ebf\u7a0b\uff09\u90fd\u6267\u884c\u76f8\u540c\u7684\u8ba1\u5212\u3002\u4e3b\u8981\u6267\u884c\u8005\u8d1f\u8d23\u5411\u5176\u4ed6\u5e76\u884c\u6267\u884c\u8005\u5206\u53d1\u8ba1\u5212\u3001\u641c\u96c6\u6570\u636e\u5e76\u5411\u5ba2\u6237\u8fd4\u56de\u6700\u7ec8\u7ed3\u679c\u3002\u4e0d\u7ba1\u662f\u4e3b\u6267\u884c\u8005\uff0c\u8fd8\u662f\u4ece\u6267\u884c\u8005\uff0c\u5b83\u4eec\u6267\u884c\u7684\u8ba1\u5212\u90fd\u662f\u5b8c\u5168\u76f8\u540c\u7684\u3002<\/p>\n<h3 id=\"22-8-1-\u591a\u673a\u5e76\u884c\u67e5\u8be2\" class=\"article-heading\" style=\"position: relative;\">22.8.1 \u591a\u673a\u5e76\u884c\u67e5\u8be2<a class=\"article-anchor\" href=\"#22.8.1 \u591a\u673a\u5e76\u884c\u67e5\u8be2\" aria-hidden=\"true\"><\/a><\/p>\n<div id=\"22.8.1 \u591a\u673a\u5e76\u884c\u67e5\u8be2\" style=\"position: absolute; top: -100px;\"><\/div>\n<\/h3>\n<p>\u591a\u673a\u5e76\u884c\u67e5\u8be2\u662f\u6307\u5728\u5206\u5e03\u5f0f\u6570\u636e\u5e93\u7cfb\u7edf\u4e2d\uff0c\u5229\u7528\u96c6\u7fa4\u4e2d\u7684\u591a\u53f0\u673a\u5668\u540c\u65f6\u5b8c\u6210\u7528\u6237\u8bf7\u6c42\u3002<\/p>\n<p>\u4f8b\u5982\uff0cDM MPP \u5c31\u662f\u4e00\u4e2a\u652f\u6301\u591a\u673a\u5e76\u884c\u7684\u6570\u636e\u5e93\u7cfb\u7edf\u3002\u7528\u6237\u767b\u5f55\u5230\u67d0\u4e2a EP \u6267\u884c\u67e5\u8be2\u64cd\u4f5c\u65f6\uff0c\u67e5\u8be2\u8ba1\u5212\u4f1a\u88ab\u81ea\u52a8\u6253\u5305\u53d1\u9001\u7ed9\u96c6\u7fa4\u4e2d\u5176\u5b83 EP\uff0c\u591a\u4e2a EP \u534f\u540c\u5408\u4f5c\u5b8c\u6210\u7528\u6237\u8bf7\u6c42\u3002\u4e3a\u4e86\u4f7f\u5f97\u6570\u636e\u80fd\u591f\u5728\u591a\u4e2a EP \u95f4\u6d41\u52a8\uff0cMPP \u5f15\u5165\u4e86\u4e13\u95e8\u7684\u6570\u636e\u5206\u53d1\u64cd\u4f5c\u7b26\u5982 MPP GATHER\uff08MGAT\uff09\u3001MPP COLLECT\uff08MCLCT\uff09\u3001MPP BROADCAST\uff08MBRO\uff09\u548c MPP SCATTER\uff08MSCT\uff09\u3002\u8be6\u60c5\u8bf7\u53c2\u8003\u300aDM8 \u5927\u89c4\u6a21\u5e76\u884c\u5904\u7406 MPP\u300b\u3002<\/p>\n<h3 id=\"22-8-2-\u672c\u5730\u5e76\u884c\u67e5\u8be2\" class=\"article-heading\" style=\"position: relative;\">22.8.2 \u672c\u5730\u5e76\u884c\u67e5\u8be2<a class=\"article-anchor\" href=\"#22.8.2 \u672c\u5730\u5e76\u884c\u67e5\u8be2\" aria-hidden=\"true\"><\/a><\/p>\n<div id=\"22.8.2 \u672c\u5730\u5e76\u884c\u67e5\u8be2\" style=\"position: absolute; top: -100px;\"><\/div>\n<\/h3>\n<p>\u672c\u5730\u5e76\u884c\u67e5\u8be2\uff08Local Parallel Query\uff0c LPQ\uff09\u662f\u6307\u5229\u7528\u4e00\u53f0\u6570\u636e\u5e93\u670d\u52a1\u5668\u7684\u591a\u4e2a\u7ebf\u7a0b\u540c\u65f6\u6267\u884c\u67e5\u8be2\u64cd\u4f5c\u3002\u53ea\u6709\u5f53\u4e3b\u673a\u5177\u6709\u591a\u4e2a CPU \u5185\u6838\u65f6\uff0c\u5f00\u542f LPQ \u624d\u80fd\u63d0\u9ad8\u67e5\u8be2\u4efb\u52a1\u7684\u6027\u80fd\u3002<\/p>\n<h3 id=\"22-8-2-1-\u672c\u5730\u5e76\u884c\u6b65\u9aa4\" class=\"article-heading\" style=\"position: relative;\">22.8.2.1 \u672c\u5730\u5e76\u884c\u6b65\u9aa4<a class=\"article-anchor\" href=\"#22.8.2.1 \u672c\u5730\u5e76\u884c\u6b65\u9aa4\" aria-hidden=\"true\"><\/a><\/p>\n<div id=\"22.8.2.1 \u672c\u5730\u5e76\u884c\u6b65\u9aa4\" style=\"position: absolute; top: -100px;\"><\/div>\n<\/h3>\n<p>\u8fbe\u68a6\u6570\u636e\u5e93\u901a\u8fc7\u4e09\u4e2a\u6b65\u9aa4\u6765\u5b8c\u6210\u672c\u5730\u5e76\u884c\u67e5\u8be2\uff1a\u9996\u5148\uff0c\u786e\u5b9a\u5e76\u884c\u4efb\u52a1\u6570\uff1b\u5176\u6b21\uff0c\u786e\u5b9a\u5e76\u884c\u5de5\u4f5c\u7ebf\u7a0b\u6570\uff1b\u6700\u540e\uff0c\u6267\u884c\u67e5\u8be2\u3002\u5e76\u884c\u67e5\u8be2\u76f8\u5173\u53c2\u6570\u89c1\u4e0b\u8868\uff1a<\/p>\n<p><center>\u886822.1 \u5e76\u884c\u67e5\u8be2\u76f8\u5173\u53c2\u6570<\/center><\/p>\n<table>\n<thead>\n<tr>\n<th><strong>\u53c2\u6570\u540d<\/strong><\/th>\n<th><strong>\u7f3a\u7701\u503c<\/strong><\/th>\n<th><strong>\u5c5e\u6027<\/strong><\/th>\n<th><strong>\u8bf4\u660e<\/strong><\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>MAX_PARALLEL_DEGREE<\/td>\n<td>1<\/td>\n<td>\u52a8\u6001\uff0c\u4f1a\u8bdd\u7ea7<\/td>\n<td>\u7528\u6765\u8bbe\u7f6e\u5355\u4e2a\u67e5\u8be2\u9ed8\u8ba4\u7684\u6700\u5927\u5e76\u884c\u4efb\u52a1\u4e2a\u6570\u3002\u53d6\u503c\u8303\u56f4\uff1a1~128\u3002\u7f3a\u7701\u503c 1\uff0c\u8868\u793a\u65e0\u5e76\u884c\u4efb\u52a1\u3002\u5f53 PARALLEL_POLICY \u503c\u4e3a 1 \u65f6\u8be5\u53c2\u6570\u503c\u624d\u6709\u6548\u3002<\/td>\n<\/tr>\n<tr>\n<td>PARALLEL_POLICY<\/td>\n<td>0<\/td>\n<td>\u52a8\u6001\uff0c\u4f1a\u8bdd\u7ea7<\/td>\n<td>\u7528\u6765\u5f00\u542f\u6216\u5173\u95ed\u5e76\u884c\u3002\u53d6\u503c\u8303\u56f4\uff1a0\u30011 \u548c 2\uff0c\u7f3a\u7701\u4e3a 0\u3002\u5176\u4e2d\uff0c0 \u8868\u793a\u5173\u95ed\u5e76\u884c\uff1b1 \u8868\u793a\u5f00\u542f\u81ea\u52a8\u5e76\u884c\u6a21\u5f0f\uff1b2 \u8868\u793a\u5f00\u542f\u624b\u52a8\u5e76\u884c\u6a21\u5f0f\u3002\u4e0d\u652f\u6301 HINT \u65b9\u5f0f\u6307\u5b9a\u8be5\u53c2\u6570\u3002<\/td>\n<\/tr>\n<tr>\n<td>PARALLEL_THRD_NUM<\/td>\n<td>10<\/td>\n<td>\u9759\u6001<\/td>\n<td>\u7528\u6765\u8bbe\u7f6e\u5e76\u884c\u5de5\u4f5c\u7ebf\u7a0b\u603b\u4e2a\u6570\u3002\u53d6\u503c\u8303\u56f4\uff1a1~1024\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4 id=\"22-8-2-1-1--\u542f\u7528\u672c\u5730\u5e76\u884c\u67e5\u8be2\" class=\"article-heading\" style=\"position: relative;\">22.8.2.1.1  \u542f\u7528\u672c\u5730\u5e76\u884c\u67e5\u8be2<a class=\"article-anchor\" href=\"#22.8.2.1.1 \u542f\u7528\u672c\u5730\u5e76\u884c\u67e5\u8be2\" aria-hidden=\"true\"><\/a><\/p>\n<div id=\"22.8.2.1.1 \u542f\u7528\u672c\u5730\u5e76\u884c\u67e5\u8be2\" style=\"position: absolute; top: -100px;\"><\/div>\n<\/h4>\n<p>\u4f7f\u7528 PARALLEL_POLICY \u5f00\u542f\u6216\u5173\u95ed LPQ\u30020 \u8868\u793a\u7981\u6b62 LPQ\u30021 \u91c7\u7528\u81ea\u52a8\u5e76\u884c\uff0c\u5373\u7cfb\u7edf\u5bf9\u4efb\u4f55\u4e00\u4e2a SQL \u90fd\u8bd5\u56fe\u4f7f\u7528 LPQ\uff0c\u9664\u975e\u4f7f\u7528\u4e86 HINT \u9650\u5236\u5e76\u884c\u4efb\u52a1\u4e2a\u6570\u30022 \u91c7\u7528\u624b\u52a8\u5e76\u884c\uff0c\u5373\u9664\u975e\u4f7f\u7528\u4e86 HINT \u6307\u5b9a\u4e86\u5e76\u884c\u4efb\u52a1\u4e2a\u6570\uff0c\u5426\u5219\u90fd\u4e0d\u91c7\u7528 LPQ\u3002<\/p>\n<h4 id=\"22-8-2-1-2--\u786e\u5b9a\u6700\u5927\u5e76\u884c\u4efb\u52a1\u4e2a\u6570\" class=\"article-heading\" style=\"position: relative;\">22.8.2.1.2  \u786e\u5b9a\u6700\u5927\u5e76\u884c\u4efb\u52a1\u4e2a\u6570<a class=\"article-anchor\" href=\"#22.8.2.1.2 \u786e\u5b9a\u6700\u5927\u5e76\u884c\u4efb\u52a1\u4e2a\u6570\" aria-hidden=\"true\"><\/a><\/p>\n<div id=\"22.8.2.1.2 \u786e\u5b9a\u6700\u5927\u5e76\u884c\u4efb\u52a1\u4e2a\u6570\" style=\"position: absolute; top: -100px;\"><\/div>\n<\/h4>\n<p>\u5f53\u5f00\u542f\u81ea\u52a8\u5e76\u884c\uff08PARALLEL_POLICY=1\uff09\u65f6\uff0c\u53c2\u6570 MAX_PARALLEL_DEGREE \u751f\u6548\uff0c\u63a7\u5236\u5355\u4e2a\u67e5\u8be2\u91c7\u7528\u5e76\u884c\u67e5\u8be2\u65f6\u6700\u591a\u4f7f\u7528\u7684\u7ebf\u7a0b\u6570\u3002MAX_PARALLEL_DEGREE \u7f3a\u7701\u503c\u4e3a 1\uff0c\u8868\u793a\u4e0d\u5e76\u884c\u3002\u6b64\u65f6\u82e5\u6307\u5b9a\u53c2\u6570\u5bf9\u5e94\u7684 HINT \u201cPARALLEL\u201d\uff0c\u5219\u4f7f\u7528 HINT \u503c\uff1b\u5f53\u5f00\u542f\u624b\u52a8\u5e76\u884c\uff08PARALLEL_POLICY=2\uff09\u65f6\uff0c\u53c2\u6570 MAX_PARALLEL_DEGREE \u5931\u6548\uff0c\u7528\u6237\u9700\u8981\u5728\u8bed\u53e5\u4e2d\u4f7f\u7528\u6b64\u53c2\u6570\u5bf9\u5e94\u7684 HINT \u201cPARALLEL\u201d\u6307\u5b9a\u8bed\u53e5\u7684\u6700\u5927\u5e76\u884c\u4efb\u52a1\u6570\uff0c\u5426\u5219\u4e0d\u5e76\u884c\u3002<\/p>\n<p>MAX_PARALLEL_DEGREE \u8981\u5c0f\u4e8e\u7b49\u4e8e PARALLEL_THRD_NUM\u3002\u5982\u679c MAX_PARALLEL_DEGREE \u8fc7\u5927\uff0c\u4f1a\u81ea\u52a8\u8c03\u6574\u4e3a\u7b49\u4e8e PARALLEL_THRD_NUM\u3002<\/p>\n<p><strong>1\uff0e<\/strong>  <strong>\u5728 INI \u53c2\u6570\u4e2d\u8bbe\u7f6e\u9ed8\u8ba4\u503c<\/strong><\/p>\n<p>INI \u53c2\u6570 MAX_PARALLEL_DEGREE \u8bbe\u7f6e\u5355\u4e2a\u67e5\u8be2\u6700\u5927\u5e76\u884c\u4efb\u52a1\u4e2a\u6570\u3002\u53d6\u503c\u8303\u56f4\uff1a1~128\u3002\u7f3a\u7701\u503c 1\uff0c\u8868\u793a\u65e0\u5e76\u884c\u4efb\u52a1\uff0c\u6b64\u53c2\u6570\u4ec5\u5728 PARALLEL_POLICY \u503c\u4e3a 1 \u65f6\u624d\u6709\u6548\u3002<\/p>\n<p>\u4f8b \u5728 INI \u53c2\u6570\u4e2d\u5c06 MAX_PARALLEL_DEGREE \u8bbe\u7f6e\u4e3a 3 \u7684\u683c\u5f0f\u5982\u4e0b\uff1a<\/p>\n<pre><a class=\"btn-copy\" data-clipboard-target=\"\" style=\"text-align: center; float: right; margin-left: -64px; width: 64px; color: rgb(148, 163, 234); cursor: pointer; text-decoration: none; font-size: 13px; font-family: inherit; padding: 0px 0.3rem; position: relative; background: rgb(244, 244, 244); z-index: 9;\"><span>Copy<\/span><\/a><code class=\"language-plaintext hljs\" style=\"background: rgb(244, 244, 244);\">MAX_PARALLEL_DEGREE   3\n<\/code><\/pre>\n<p>\u7136\u540e\uff0c\u4f7f\u7528\u4e00\u822c\u7684 SQL \u8bed\u53e5\u67e5\u8be2\u5373\u53ef\u6267\u884c\u5e76\u884c\u67e5\u8be2\uff0c\u4e0d\u9700\u8981\u4f7f\u7528 HINT\u3002\u5982\uff1a<\/p>\n<pre><a class=\"btn-copy\" data-clipboard-target=\"\" style=\"text-align: center; float: right; margin-left: -64px; width: 64px; color: rgb(148, 163, 234); cursor: pointer; text-decoration: none; font-size: 13px; font-family: inherit; padding: 0px 0.3rem; position: relative; background: rgb(244, 244, 244); z-index: 9;\"><span>Copy<\/span><\/a><code class=\"language-plaintext hljs\" style=\"background: rgb(244, 244, 244);\">SELECT * FROM SYSOBJECTS;\n<\/code><\/pre>\n<p><strong>2\uff0e<\/strong>  <strong>\u5728 SQL \u8bed\u53e5\u4e2d\u4f7f\u7528\u201cPARALLEL\u201d\u5173\u952e\u5b57\u7279\u522b\u6307\u5b9a<\/strong><\/p>\n<p>\u5f53 PARALLEL_POLICY=2 \u65f6\uff0c\u9700\u8981\u5728 SQL \u8bed\u53e5\u4e2d\u901a\u8fc7\u201cPARALLEL\u201dHINT \u6307\u5b9a\u5e76\u884c\u5ea6\uff0c\u5426\u5219\u4e0d\u5e76\u884c\u3002\u82e5 PARALLEL_POLICY=1\uff0c\u5219 SQL \u8bed\u53e5\u4e2d\u4f7f\u7528\u7684\u201cPARALLEL\u201dHINT \u603b\u662f\u4f18\u5148\u4e8e MAX_PARALLEL_DEGREE \u53c2\u6570\u8bbe\u7f6e\u3002<\/p>\n<p>\u201cPARALLEL\u201d\u5173\u952e\u5b57\u7684\u7528\u6cd5\u662f\u5728\u6570\u636e\u67e5\u8be2\u8bed\u53e5\u7684 SELECT \u5173\u952e\u5b57\u540e\uff0c\u589e\u52a0 HINT \u5b50\u53e5\u6765\u5b9e\u73b0\u3002<\/p>\n<p>HINT \u8bed\u6cd5\u683c\u5f0f\u5982\u4e0b\uff1a<\/p>\n<pre><a class=\"btn-copy\" data-clipboard-target=\"\" style=\"text-align: center; float: right; margin-left: -64px; width: 64px; color: rgb(148, 163, 234); cursor: pointer; text-decoration: none; font-size: 13px; font-family: inherit; padding: 0px 0.3rem; position: relative; background: rgb(244, 244, 244); z-index: 9;\"><span>Copy<\/span><\/a><code class=\"language-plaintext hljs\" style=\"background: rgb(244, 244, 244);\">\/*+ PARALLEL([&lt;\u8868\u540d&gt;] &lt;\u5e76\u884c\u4efb\u52a1\u4e2a\u6570&gt;) *\/\n<\/code><\/pre>\n<p>\u4f8b \u4e0b\u9762\u7684\u4f8b\u5b50\u4e2d\uff0c\u5373\u4f7f\u5df2\u7ecf\u8bbe\u7f6e\u4e86 MAX_PARALLEL_DEGREE \u9ed8\u8ba4\u503c 3\uff0c\u4f46\u5b9e\u9645\u4f7f\u7528\u7684\u4e3a PARALLEL \u6307\u5b9a\u7684\u4efb\u52a1\u4e2a\u6570 4\uff1a<\/p>\n<pre><a class=\"btn-copy\" data-clipboard-target=\"\" style=\"text-align: center; float: right; margin-left: -64px; width: 64px; color: rgb(148, 163, 234); cursor: pointer; text-decoration: none; font-size: 13px; font-family: inherit; padding: 0px 0.3rem; position: relative; background: rgb(244, 244, 244); z-index: 9;\"><span>Copy<\/span><\/a><code class=\"language-plaintext hljs\" style=\"background: rgb(244, 244, 244);\">SELECT \/*+ PARALLEL(4) *\/ * FROM SYSOBJECTS;\n<\/code><\/pre>\n<p>\u53e6\u5916\uff0c\u6bcf\u4e2a\u8bed\u53e5\u4e2d\u4ec5\u80fd\u8bbe\u7f6e\u4e00\u6b21\u5e76\u884c\u4efb\u52a1\u4e2a\u6570\uff0c\u5982\u679c\u8bbe\u7f6e\u4e86\u591a\u6b21\uff0c\u5219\u4ee5\u7b2c\u4e00\u6b21\u8bbe\u7f6e\u4e3a\u51c6\uff0c\u800c\u4e14\u4efb\u52a1\u4e2a\u6570\u5728\u5168\u8bed\u53e5\u4e2d\u751f\u6548\u3002<\/p>\n<p>\u4f8b \u4e0b\u9762\u7684\u4f8b\u5b50\u4e2d\uff0c\u4f7f\u7528\u7684\u5e76\u884c\u4efb\u52a1\u4e2a\u6570\u4e3a 1\u3002<\/p>\n<pre><a class=\"btn-copy\" data-clipboard-target=\"\" style=\"text-align: center; float: right; margin-left: -64px; width: 64px; color: rgb(148, 163, 234); cursor: pointer; text-decoration: none; font-size: 13px; font-family: inherit; padding: 0px 0.3rem; position: relative; background: rgb(244, 244, 244); z-index: 9;\"><span>Copy<\/span><\/a><code class=\"language-plaintext hljs\" style=\"background: rgb(244, 244, 244);\">SELECT \/*+ PARALLEL(1) *\/\/*+ PARALLEL(2) *\/ * FROM SYSOBJECTS;\n<\/code><\/pre>\n<p>\u8fd9\u79cd\u65b9\u5f0f\u80fd\u591f\u4e3a\u5355\u6761\u67e5\u8be2\u8bed\u53e5\u8bbe\u7f6e\u989d\u5916\u7684\u5e76\u884c\u4efb\u52a1\u4e2a\u6570\uff0c\u4ee5\u6b64\u6765\u63d0\u9ad8\u67d0\u4e9b\u7279\u6b8a\u67e5\u8be2\u4efb\u52a1\u7684\u6027\u80fd\u3002<\/p>\n<h4 id=\"22-8-2-1-3--\u786e\u5b9a\u5e76\u884c\u5de5\u4f5c\u7ebf\u7a0b\u603b\u4e2a\u6570\" class=\"article-heading\" style=\"position: relative;\">22.8.2.1.3  \u786e\u5b9a\u5e76\u884c\u5de5\u4f5c\u7ebf\u7a0b\u603b\u4e2a\u6570<a class=\"article-anchor\" href=\"#22.8.2.1.3 \u786e\u5b9a\u5e76\u884c\u5de5\u4f5c\u7ebf\u7a0b\u603b\u4e2a\u6570\" aria-hidden=\"true\"><\/a><\/p>\n<div id=\"22.8.2.1.3 \u786e\u5b9a\u5e76\u884c\u5de5\u4f5c\u7ebf\u7a0b\u603b\u4e2a\u6570\" style=\"position: absolute; top: -100px;\"><\/div>\n<\/h4>\n<p>\u5728\u6267\u884c\u5e76\u884c\u67e5\u8be2\u4efb\u52a1\u4e4b\u524d\uff0c\u60a8\u9700\u8981\u6307\u5b9a\u5b8c\u6210\u5e76\u884c\u67e5\u8be2\u7684\u5e76\u884c\u5de5\u4f5c\u7ebf\u7a0b\u603b\u4e2a\u6570\u3002\u5e76\u884c\u5de5\u4f5c\u7ebf\u7a0b\u603b\u6570\u662f\u7cfb\u7edf\u542f\u52a8\u65f6\uff0c\u521b\u5efa\u7684\u5e76\u884c\u5de5\u4f5c\u7ebf\u7a0b\u7684\u603b\u4e2a\u6570\uff0c\u4e00\u822c\u4e0d\u8d85\u8fc7 CPU \u5185\u6838\u4e2a\u6570\u7684 2 \u500d\u3002<\/p>\n<p>\u503c\u5f97\u6ce8\u610f\u7684\u662f\uff0c\u5b9e\u9645\u4f7f\u7528\u7684\u7ebf\u7a0b\u6570\u5e76\u975e\u603b\u662f\u7b49\u4e8e\u5e76\u884c\u5de5\u4f5c\u7ebf\u7a0b\u603b\u6570\u3002\u5e76\u884c\u5de5\u4f5c\u7ebf\u7a0b\u603b\u6570\u662f\u5728 INI \u53c2\u6570\u4e2d\u8bbe\u5b9a\u7684\uff0c\u5b9e\u9645\u4f7f\u7528\u5e76\u884c\u5de5\u4f5c\u7ebf\u7a0b\u6570\u662f\u6839\u636e\u7cfb\u7edf\u7684\u5b9e\u9645\u72b6\u51b5\u786e\u5b9a\u7684\u3002<\/p>\n<p><strong>1\uff0e<\/strong>  <strong>\u5e76\u884c\u5de5\u4f5c\u7ebf\u7a0b\u6570\uff0c\u5728 INI \u53c2\u6570\u4e2d\u8bbe\u5b9a<\/strong><\/p>\n<p>\u9996\u5148\uff0c\u4f7f\u7528 PARALLEL_POLICY \u53c2\u6570\u6765\u8bbe\u7f6e\u5e76\u884c\u7b56\u7565\u3002\u53d6\u503c\u8303\u56f4\uff1a0\u30011 \u548c 2\uff0c\u9ed8\u8ba4\u503c 0\u3002\u5176\u4e2d\uff0c0 \u8868\u793a\u4e0d\u652f\u6301\u5e76\u884c\uff1b1 \u8868\u793a\u81ea\u52a8\u5e76\u884c\u6a21\u5f0f\uff1b2 \u8868\u793a\u624b\u52a8\u5e76\u884c\u6a21\u5f0f\u3002<\/p>\n<p>\u5f53\u5f00\u542f\u672c\u5730\u5e76\u884c\uff08PARALLEL_POLICY&gt;0\uff09\u65f6\uff0c\u4f7f\u7528 PARALLEL_THRD_NUM \u6307\u5b9a\u672c\u5730\u5e76\u884c\u67e5\u8be2\u4f7f\u7528\u7684\u7ebf\u7a0b\u6570\uff0c\u53d6\u503c\u8303\u56f4\u4e3a 1~1024\uff0c\u7f3a\u7701\u503c\u4e3a 10\u3002\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u82e5 PARALLEL_POLICY=1\uff0c\u5982\u679c PARALLEL_THRD_NUM=1, \u5219\u6309\u7167 CPU \u4e2a\u6570\u521b\u5efa\u5e76\u884c\u7ebf\u7a0b\u3002<\/p>\n<p>\u4f8b \u8bbe\u7f6e\u5e76\u884c\u7b56\u7565 PARALLEL_POLICY \u4e3a 2\uff0c\u5373\u624b\u52a8\u8bbe\u7f6e\u5e76\u884c\u5de5\u4f5c\u7ebf\u7a0b\u6570\uff1b\u540c\u65f6\uff0c\u8bbe\u7f6e\u5e76\u884c\u5de5\u4f5c\u7ebf\u7a0b\u6570 PARALLEL_THRD_NUM \u4e3a 4 \u4e2a\u3002<\/p>\n<pre><a class=\"btn-copy\" data-clipboard-target=\"\" style=\"text-align: center; float: right; margin-left: -64px; width: 64px; color: rgb(148, 163, 234); cursor: pointer; text-decoration: none; font-size: 13px; font-family: inherit; padding: 0px 0.3rem; position: relative; background: rgb(244, 244, 244); z-index: 9;\"><span>Copy<\/span><\/a><code class=\"language-plaintext hljs\" style=\"background: rgb(244, 244, 244);\">PARALLEL_POLICY      2\n\nPARALLEL_THRD_NUM    4\n<\/code><\/pre>\n<p>\u5f53\u7136\uff0c\u5e76\u975e\u6240\u6709\u7684\u67e5\u8be2\u90fd\u9002\u5408\u4f7f\u7528\u5e76\u884c\u67e5\u8be2\u3002\u5927\u91cf\u5360\u7528 CPU \u5468\u671f\u7684\u67e5\u8be2\u6700\u9002\u5408\u91c7\u7528\u5e76\u884c\u67e5\u8be2\u7684\u529f\u80fd\u3002\u4f8b\u5982\uff0c\u5927\u578b\u8868\u7684\u8fde\u63a5\u67e5\u8be2\u3001\u5927\u91cf\u6570\u636e\u7684\u805a\u5408\u548c\u5927\u578b\u7ed3\u679c\u96c6\u7684\u6392\u5e8f\u7b49\u90fd\u5f88\u9002\u5408\u91c7\u7528\u5e76\u884c\u67e5\u8be2\u3002\u5bf9\u4e8e\u7b80\u5355\u67e5\u8be2\uff08\u5e38\u7528\u4e8e\u4e8b\u52a1\u5904\u7406\u5e94\u7528\u7a0b\u5e8f\uff09\u800c\u8a00\uff0c\u6267\u884c\u5e76\u884c\u67e5\u8be2\u6240\u9700\u7684\u989d\u5916\u534f\u8c03\u5de5\u4f5c\u4f1a\u5927\u4e8e\u6f5c\u5728\u7684\u6027\u80fd\u63d0\u5347\u3002\u6240\u4ee5\uff0c\u6570\u636e\u5e93\u7ba1\u7406\u5458\u5728\u786e\u5b9a\u662f\u5426\u9700\u8981\u4f7f\u7528\u5e76\u884c\u7b56\u7565\u7684\u65f6\u5019\uff0c\u9700\u8981\u614e\u91cd\u3002<\/p>\n<p><strong>2\uff0e<\/strong>  <strong>\u5b9e\u9645\u4f7f\u7528\u7684\u7ebf\u7a0b\u6570\uff0c\u8fbe\u68a6\u6570\u636e\u5e93\u4f1a\u6839\u636e\u6bcf\u4e2a\u5e76\u884c\u67e5\u8be2\u64cd\u4f5c\u81ea\u52a8\u68c0\u6d4b<\/strong><\/p>\n<p>\u5b9e\u9645\u4f7f\u7528\u7ebf\u7a0b\u6570\u662f\u6570\u636e\u5e93\u5728\u67e5\u8be2\u8ba1\u5212\u6267\u884c\u65f6\u521d\u59cb\u5316\u7684\u65f6\u5019\u786e\u5b9a\u7684\u3002\u4e5f\u5c31\u662f\u8bf4\uff0c\u8fd9\u4e0d\u9700\u8981\u7528\u6237\u53bb\u5e72\u9884\uff0c\u800c\u662f\u7cfb\u7edf\u6839\u636e\u5e76\u884c\u4efb\u52a1\u6570\u548c\u5b9e\u9645\u7a7a\u95f2\u7684\u5e76\u884c\u5de5\u4f5c\u7ebf\u7a0b\u6570\u6765\u786e\u5b9a\u7684\u3002\u6b64\u64cd\u4f5c\u6240\u4f9d\u636e\u7684\u6761\u4ef6\u5982\u4e0b\uff1a\u9996\u5148\uff0c\u68c0\u6d4b\u8fbe\u68a6\u6570\u636e\u5e93\u662f\u5426\u8fd0\u884c\u5728\u5177\u6709\u591a\u4e2a CPU \u7684\u8ba1\u7b97\u673a\u4e0a\u3002\u53ea\u6709\u5177\u6709\u591a\u4e2a CPU \u7684\u8ba1\u7b97\u673a\u624d\u80fd\u4f7f\u7528\u5e76\u884c\u67e5\u8be2\u3002\u8fd9\u662f\u4e00\u4e2a\u786c\u6027\u7684\u9650\u5236\u6761\u4ef6\u3002\u5176\u6b21\uff0c\u68c0\u6d4b\u53ef\u7528\u7684\u7a7a\u95f2\u5de5\u4f5c\u7ebf\u7a0b\u662f\u5426\u8db3\u591f\u3002\u5e76\u884c\u67e5\u8be2\u5230\u5e95\u91c7\u7528\u591a\u5c11\u7ebf\u7a0b\u6570\uff0c\u9664\u4e86\u8ddf\u64cd\u4f5c\u7684\u590d\u6742\u7a0b\u5ea6\u76f8\u5173\u5916\uff0c\u8fd8\u8ddf\u5f53\u65f6\u7684\u670d\u52a1\u5668\u72b6\u6001\u76f8\u5173\uff0c\u5982\u662f\u5426\u6709\u8db3\u591f\u7684\u53ef\u7528\u7684\u7a7a\u95f2\u5de5\u4f5c\u7ebf\u7a0b\u6570\u91cf\u7b49\u3002\u6bcf\u4e2a\u5e76\u884c\u67e5\u8be2\u64cd\u4f5c\u90fd\u8981\u6c42\u4e00\u5b9a\u7684\u5de5\u4f5c\u7ebf\u7a0b\u6570\u91cf\u624d\u80fd\u591f\u6267\u884c\uff1b\u800c\u4e14\u6267\u884c\u5e76\u884c\u8ba1\u5212\u6bd4\u6267\u884c\u4e32\u884c\u8ba1\u5212\u9700\u8981\u66f4\u591a\u7684\u7ebf\u7a0b\uff0c\u6240\u9700\u8981\u7684\u7ebf\u7a0b\u6570\u91cf\u4e5f\u4f1a\u968f\u7740\u4efb\u52a1\u4e2a\u6570\u7684\u63d0\u9ad8\u800c\u589e\u52a0\u3002\u5f53\u65e0\u6cd5\u6ee1\u8db3\u7279\u5b9a\u5e76\u884c\u67e5\u8be2\u6267\u884c\u7684\u7ebf\u7a0b\u8981\u6c42\u65f6\uff0c\u6570\u636e\u5e93\u5f15\u64ce\u5c31\u4f1a\u81ea\u52a8\u51cf\u5c11\u4efb\u52a1\u4e2a\u6570\uff0c\u751a\u81f3\u4f1a\u653e\u5f03\u5e76\u884c\u67e5\u8be2\u800c\u6539\u4e3a\u4e32\u884c\u8ba1\u5212\u3002\u6240\u4ee5\uff0c\u5373\u4f7f\u540c\u4e00\u4e2a\u64cd\u4f5c\u5728\u4e0d\u540c\u65f6\u5019\u53ef\u80fd\u4f1a\u91c7\u7528\u4e0d\u540c\u7684\u7ebf\u7a0b\u6570\u3002<\/p>\n<p>\u4f8b\u5982\uff0c\u5373\u4f7f\u8bbe\u7f6e\u5e76\u884c\u5de5\u4f5c\u7ebf\u7a0b\u6570\u4e3a 4\u3002\u800c\u5b9e\u9645\u4f7f\u7528\u7684\u7ebf\u7a0b\u6570\u53ef\u80fd\u53ea\u6709 3 \u4e2a\uff0c\u6216\u8005\u66f4\u5c11\u3002<\/p>\n<h4 id=\"22-8-2-1-4--\u6267\u884c\u67e5\u8be2\" class=\"article-heading\" style=\"position: relative;\">22.8.2.1.4  \u6267\u884c\u67e5\u8be2<a class=\"article-anchor\" href=\"#22.8.2.1.4 \u6267\u884c\u67e5\u8be2\" aria-hidden=\"true\"><\/a><\/p>\n<div id=\"22.8.2.1.4 \u6267\u884c\u67e5\u8be2\" style=\"position: absolute; top: -100px;\"><\/div>\n<\/h4>\n<p>\u5f53\u4ee5\u4e0a\u5185\u5bb9\u786e\u5b9a\u597d\u4e4b\u540e\uff0c\u6570\u636e\u5e93\u5c31\u4f1a\u6267\u884c\u5177\u4f53\u7684\u67e5\u8be2\u4efb\u52a1\u3002\u4f8b\u5982\uff0c\u5f53\u5f00\u542f\u4e86\u81ea\u52a8\u5e76\u884c\u6a21\u5f0f PARALLEL_POLICY=1\uff0c\u6700\u5927\u5e76\u884c\u4efb\u52a1\u6570\u4e3a 16\uff0c\u5e76\u884c\u7ebf\u7a0b\u603b\u4e2a\u6570\u4e3a 32\u3002\u5728\u8fd9\u79cd\u642d\u914d\u4e0b\uff0c\u5f53\u4ee5 16 \u8def\u5e76\u884c\u65f6\uff0c\u6700\u591a\u53ef\u4ee5\u6709 2 \u4e2a SQL \u91c7\u7528\u5e76\u884c\u67e5\u8be2\uff0c\u5e76\u884c\u7ebf\u7a0b\u603b\u6570\u4e0d\u8d85\u8fc7 32\uff0c\u6b64\u65f6\uff0c\u5982\u679c\u6709\u5176\u4ed6 SQL\uff0c\u53ea\u80fd\u91c7\u7528\u975e\u5e76\u884c\u67e5\u8be2\u3002<\/p>\n<h3 id=\"22-8-2-2-\u672c\u5730\u5e76\u884c\u64cd\u4f5c\u7b26\" class=\"article-heading\" style=\"position: relative;\">22.8.2.2 \u672c\u5730\u5e76\u884c\u64cd\u4f5c\u7b26<a class=\"article-anchor\" href=\"#22.8.2.2 \u672c\u5730\u5e76\u884c\u64cd\u4f5c\u7b26\" aria-hidden=\"true\"><\/a><\/p>\n<div id=\"22.8.2.2 \u672c\u5730\u5e76\u884c\u64cd\u4f5c\u7b26\" style=\"position: absolute; top: -100px;\"><\/div>\n<\/h3>\n<p>\u4e3a\u4e86\u4f7f\u5f97\u6570\u636e\u5728\u540c\u4e00\u8fdb\u7a0b\u7684\u4e0d\u540c\u7ebf\u7a0b\u95f4\u6d41\u52a8\uff0c\u5f15\u5165\u4e86 4 \u4e2a\u7528\u4e8e\u672c\u5730\u6570\u636e\u5206\u53d1\u7684\u64cd\u4f5c\u7b26\uff1aLOCAL GATHER\uff08LGAT\uff09\u3001LOCAL DISTRIBUTE\uff08LDIS\uff09\u3001LOCAL BROADCAST\uff08LBRO\uff09\u548c LOCAL SCATTER\uff08LSCT\uff09\u3002<\/p>\n<p><center>\u886822.2 LPQ\u5e76\u884c\u6267\u884c\u8ba1\u5212\u901a\u8baf\u64cd\u4f5c\u7b26<\/center><\/p>\n<table>\n<thead>\n<tr>\n<th><strong>\u64cd\u4f5c\u7b26\u540d\u79f0<\/strong><\/th>\n<th><strong>\u529f\u80fd<\/strong><\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>LOCAL GATHER  \uff08LGAT\uff09<\/td>\n<td>\u4e3b\u7ebf\u7a0b\u6536\u96c6\u6240\u6709\u7ebf\u7a0b\u6570\u636e\uff0c\u4ece\u7ebf\u7a0b\u5c06\u6570\u636e\u53d1\u9001\u5230\u4e3b\u7ebf\u7a0b<\/td>\n<\/tr>\n<tr>\n<td>LOCAL DISTRIBUTE  \uff08LDIS\uff09<\/td>\n<td>\u5404\u7ebf\u7a0b\u95f4\u76f8\u4e92\u5206\u53d1\u6570\u636e\uff0c\u6309\u7167\u5206\u53d1\u5217\u8ba1\u7b97\u884c\u6570\u636e\u7684\u76ee\u6807\u7ebf\u7a0b\u5e76\u53d1\u9001\u8fc7\u53bb\uff0c\u76ee\u6807\u7ebf\u7a0b\u8d1f\u8d23\u63a5\u6536<\/td>\n<\/tr>\n<tr>\n<td>LOCAL BROADCAST  \uff08LBRO\uff09<\/td>\n<td>\u6536\u96c6\u6570\u636e\u5230\u4e3b\u7ebf\u7a0b\uff0c\u8be5\u64cd\u4f5c\u7b26\u5e26\u6709\u805a\u96c6\u51fd\u6570\u8fd0\u7b97\u529f\u80fd\uff0c\u4ec5\u548c FAGR \u914d\u5408\u4f7f\u7528<\/td>\n<\/tr>\n<tr>\n<td>LOCAL SCATTER  \uff08LSCT\uff09<\/td>\n<td>\u4e3b\u7ebf\u7a0b\u53d1\u9001\u5b8c\u6574\u6570\u636e\u5230\u6240\u6709\u4ece\u7ebf\u7a0b\uff0c\u4fdd\u8bc1\u6bcf\u4e2a\u7ebf\u7a0b\u6570\u636e\u90fd\u5b8c\u6574\uff0c\u4e00\u822c\u548c LGAT \u914d\u5408\u4f7f\u7528<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3 id=\"22-8-2-3-\u4f7f\u7528\u573a\u666f\" class=\"article-heading\" style=\"position: relative;\">22.8.2.3 \u4f7f\u7528\u573a\u666f<a class=\"article-anchor\" href=\"#22.8.2.3 \u4f7f\u7528\u573a\u666f\" aria-hidden=\"true\"><\/a><\/p>\n<div id=\"22.8.2.3 \u4f7f\u7528\u573a\u666f\" style=\"position: absolute; top: -100px;\"><\/div>\n<\/h3>\n<p>\u4f7f\u7528\u624b\u52a8\u5e76\u884c\u6a21\u5f0f\u65f6\uff0c\u53ea\u9700\u8981\u5728 INI \u53c2\u6570\u4e2d\u8bbe\u7f6e\u597d\u5982\u4e0b 2 \u4e2a\u53c2\u6570\uff0c\u7136\u540e\u6267\u884c\u5e76\u884c SQL \u67e5\u8be2\u8bed\u53e5\u65f6\uff0c\u9700\u624b\u52a8\u6307\u5b9a\u5f53\u524d\u5e76\u884c\u4efb\u52a1\u4e2a\u6570\u3002\u82e5\u4e0d\u6307\u5b9a\uff0c\u5c06\u4e0d\u4f7f\u7528\u5e76\u884c\u3002\u8bbe\u7f6e\u7684 2 \u4e2a\u53c2\u6570\u5982\u4e0b\uff1a<\/p>\n<pre><a class=\"btn-copy\" data-clipboard-target=\"\" style=\"text-align: center; float: right; margin-left: -64px; width: 64px; color: rgb(148, 163, 234); cursor: pointer; text-decoration: none; font-size: 13px; font-family: inherit; padding: 0px 0.3rem; position: relative; background: rgb(244, 244, 244); z-index: 9;\"><span>Copy<\/span><\/a><code class=\"language-plaintext hljs\" style=\"background: rgb(244, 244, 244);\">PARALLEL_POLICY      2\n\nPARALLEL_THRD_NUM    4\n<\/code><\/pre>\n<p>\u4f7f\u7528\u81ea\u52a8\u5e76\u884c\u6a21\u5f0f\u65f6\uff0c\u4e00\u822c\u6307\u5b9a\u5982\u4e0b\u4e09\u4e2a\u53c2\u6570\uff1a<\/p>\n<pre><a class=\"btn-copy\" data-clipboard-target=\"\" style=\"text-align: center; float: right; margin-left: -64px; width: 64px; color: rgb(148, 163, 234); cursor: pointer; text-decoration: none; font-size: 13px; font-family: inherit; padding: 0px 0.3rem; position: relative; background: rgb(244, 244, 244); z-index: 9;\"><span>Copy<\/span><\/a><code class=\"language-plaintext hljs\" style=\"background: rgb(244, 244, 244);\">MAX_PARALLEL_DEGREE   3\n\nPARALLEL_POLICY       1\n\nPARALLEL_THRD_NUM     10\n<\/code><\/pre>\n<p>\u53e6\u5916\uff0c\u5f53 PARALLEL_POLICY \u4e3a 0 \u65f6\uff0c\u5373\u4f7f\u6709\u5e76\u884c\u4efb\u52a1\uff0c\u4e5f\u4e0d\u652f\u6301\u5e76\u884c\u3002<\/p>\n<p>\u7136\u540e\uff0c\u6267\u884c\u8bed\u6cd5\u683c\u5f0f\u7c7b\u4f3c\u201cSELECT * FROM SYSOBJECTS;\u201d\u7684\u5e76\u884c SQL \u8bed\u53e5\u5373\u53ef\uff0c\u672c\u6761\u8bed\u53e5\u4f7f\u7528\u9ed8\u8ba4\u5e76\u884c\u4efb\u52a1\u6570 3\u3002<\/p>\n<p>\u5f53\u7136\uff0c\u5982\u679c\u5355\u6761\u67e5\u8be2\u8bed\u53e5\u4e0d\u60f3\u4f7f\u7528\u9ed8\u8ba4\u5e76\u884c\u4efb\u52a1\u6570\uff0c\u53ef\u4ee5\u901a\u8fc7\u5728 SQL \u8bed\u53e5\u4e2d\u589e\u52a0 HINT\uff0c\u901a\u8fc7\u201cPARALLEL\u201d\u5173\u952e\u5b57\u6765\u7279\u522b\u6307\u5b9a\u3002\u6b64\u65f6\uff0c\u6267\u884c\u7684\u5e76\u884c SQL \u8bed\u53e5\u683c\u5f0f\u4e3a\u201cSELECT \/*+ PARALLEL(SYSOBJECTS 4) *\/ * FROM SYSOBJECTS;\u201d\uff0c\u672c\u6761\u8bed\u53e5\u4f7f\u7528\u7684\u5e76\u884c\u4efb\u52a1\u6570\u4e3a 4\u3002<\/p>\n<h3 id=\"22-8-3-\u591a\u673a\u548c\u672c\u5730\u5e76\u884c\u67e5\u8be2\" class=\"article-heading\" style=\"position: relative;\">22.8.3 \u591a\u673a\u548c\u672c\u5730\u5e76\u884c\u67e5\u8be2<a class=\"article-anchor\" href=\"#22.8.3 \u591a\u673a\u548c\u672c\u5730\u5e76\u884c\u67e5\u8be2\" aria-hidden=\"true\"><\/a><\/p>\n<div id=\"22.8.3 \u591a\u673a\u548c\u672c\u5730\u5e76\u884c\u67e5\u8be2\" style=\"position: absolute; top: -100px;\"><\/div>\n<\/h3>\n<p>\u5728 DM MPP \u7cfb\u7edf\u4e2d\u5f00\u542f LPQ\uff0c\u8ba1\u5212\u6267\u884c\u65f6\u5c31\u4f1a\u7528\u5230\u591a\u673a\u5e76\u884c\u548c\u672c\u5730\u5e76\u884c\u3002\u5982\u4e0b\u9762 TPCH \u7684 Q1 \u67e5\u8be2\u8bed\u53e5\u3002<\/p>\n<pre><a class=\"btn-copy\" data-clipboard-target=\"\" style=\"text-align: center; float: right; margin-left: -64px; width: 64px; color: rgb(148, 163, 234); cursor: pointer; text-decoration: none; font-size: 13px; font-family: inherit; padding: 0px 0.3rem; position: relative; background: rgb(244, 244, 244); z-index: 9;\"><span>Copy<\/span><\/a><code class=\"language-plaintext hljs\" style=\"background: rgb(244, 244, 244);\">select\n\nl_returnflag,  \n\nl_linestatus,  \n\nsum(l_quantity) as sum_qty,   \n\nsum(l_extendedprice) as sum_base_price,   \n\nsum(l_extendedprice*(1-l_discount)) as sum_disc_price,   \n\nsum(l_extendedprice*(1-l_discount)*(1+l_tax)) as sum_charge,  \n\navg(l_quantity) as avg_qty,   \n\navg(l_extendedprice) as avg_price,  \n\navg(l_discount) as avg_disc,  \n\ncount(*) as count_order   \n\nfrom lineitem  \n\nwhere l_shipdate &lt;= date' 1998-12-01' - interval '90' day  \n\ngroup by l_returnflag, l_linestatus   \n\norder by l_returnflag, l_linestatus;\n<\/code><\/pre>\n<p>\u8be5\u67e5\u8be2\u4e3a\u5355\u8868\u8fc7\u6ee4\u540e\u7684\u5206\u7ec4\u548c\u6392\u5e8f\u3002\u7531\u4e8e\u540c\u4e00\u5206\u7ec4\u7684\u6570\u636e\u53ef\u80fd\u5206\u6563\u5728\u591a\u4e2a EP \u7684\u4e0d\u540c\u7ebf\u7a0b\u95f4\uff0c\u8ba1\u5212\u4e2d\u9700\u8981\u5bf9\u5206\u7ec4\u7ed3\u679c\u8fdb\u884c\u591a\u6b21\u5904\u7406\u3002\u4e00\u4e2a\u53ef\u80fd\u7684\u8ba1\u5212\u5f62\u6001\u5982\u4e0b\uff1a<\/p>\n<pre><a class=\"btn-copy\" data-clipboard-target=\"\" style=\"text-align: center; float: right; margin-left: -64px; width: 64px; color: rgb(148, 163, 234); cursor: pointer; text-decoration: none; font-size: 13px; font-family: inherit; padding: 0px 0.3rem; position: relative; background: rgb(244, 244, 244); z-index: 9;\"><span>Copy<\/span><\/a><code class=\"language-plaintext hljs\" style=\"background: rgb(244, 244, 244);\">1  ##NSET2: [23339, 1, 140] \n\n2   ##MPP COLLECT: [23339, 1, 140]; op_id(8) n_grp_by (0) n_cols(0) n_keys(0) for_sync(TRUE)\n\n3    ##LOCAL COLLECT: [23339, 1, 140]; op_id(7) n_grp_by (0) n_cols(0) n_keys(0) for_sync(TRUE)\n\n4     ##PRJT2: [23339, 1, 140]; exp_num(10), is_atom(FALSE) \n\n5      ##MPP GATHER: [23339, 6, 140]; op_id(6) n_grp_by (0) n_cols(10) n_keys(2) invoke_flag(0)\n\n6       ##LOCAL GATHER: [23339, 1, 140]; op_id(5) n_grp_by (0) n_cols(10) n_keys(2) invoke_flag(0)\n\n7        ##SORT3: [23339, 1, 140]; key_num(2), is_distinct(FALSE), top_flag(0), is_adaptive(0)\n\n8         ##HAGR2: [23334, 6, 140]; grp_num(2), sfun_num(8); slave_empty(0)keys DMTEMPVIEW_16779645.TMPCOL0\n\n9          ##LOCAL DISTRIBUTE: [23334, 6, 140]; op_id(4) n_keys(0) n_grp(1) flt_only(FALSE) flt_site_data(FALSE) n(0)\n\n10          ##MPP DISTRIBUTE: [23334, 6, 140]; op_id(3) n_keys(0) n_grp(1) filter(FALSE) rowid_flag(0) n(0) slave_empty(FALSE)\n\n11           ##LOCAL GATHER: [23334, 6, 140]; op_id(2) n_grp_by (0) n_cols(0) n_keys(0) invoke_flag(0)\n\n12            ##HAGR2: [23334, 6, 140]; grp_num(2), sfun_num(9); slave_empty(0)keys DMTEMPVIEW_16779645.TMPCOL0\n\n13              ##LOCAL DISTRIBUTE: [23334, 6, 140]; op_id(1) n_keys(0) n_grp(1) flt_only(FALSE) flt_site_data(FALSE) n(0)\n\n14              ##HAGR2: [23334, 6, 140]; grp_num(2), sfun_num(9); slave_empty(0)keys DMTEMPVIEW_16779645.TMPCOL0\n\n15                ##PRJT2: [21471, 147843240, 140]; exp_num(7), is_atom(FALSE) \n\n16                ##SLCT2: [21471, 147843240, 140]; LINEITEM.L_SHIPDATE &lt;= var3\n\n17                 ##HFSCN: [21471, 150020479, 140]; (LINEITEM)\n<\/code><\/pre>\n<p>\u5047\u5b9a\u4e0a\u8ff0\u8ba1\u5212\u6267\u884c\u5728 EP1~EP4 \u5171\u56db\u4e2a EP \u4e0a\u6267\u884c\uff0c\u6bcf\u4e2a EP \u8bbe\u7f6e\u7684\u5e76\u884c\u5ea6\u4e3a 8\uff0c\u90a3\u4e48\u8be5\u8ba1\u5212\u4e00\u5171\u6709 8 * 4= 32 \u4e2a\u7ebf\u7a0b\u534f\u4f5c\u5b8c\u6210\u3002\u6267\u884c\u7684\u5927\u4f53\u6d41\u7a0b\u662f\uff0c\u9996\u5148\u6bcf\u4e2a EP \u7684 8 \u8def\u7ebf\u7a0b\u5404\u81ea\u83b7\u53d6 lineitem \u8868\u6570\u636e\uff0c\u7ecf\u8fc7\u54c8\u5e0c\u5206\u7ec4\uff08##14\uff09\u540e\u6309\u7167\u5206\u7ec4\u9879 l_returnflag, l_linestatus \u8fdb\u884c\u672c\u5730\u6570\u636e\u5206\u53d1\uff08##13\uff09\uff0c\u800c\u540e\u8fdb\u884c\u4e8c\u6b21\u54c8\u5e0c\u5206\u7ec4\u5904\u7406\uff08##12\uff09\u3002\u63a5\u4e0b\u6765\uff0c\u9700\u8981\u8003\u8651\u540c\u4e00\u5206\u7ec4\u5206\u6563\u5728\u4e0d\u540c EP \u7684\u60c5\u51b5\uff0c\u4e3a\u6b64##11 \u7684\u672c\u5730\u6c47\u603b\u5c06 8 \u4e2a\u7ebf\u7a0b\u7684\u7ed3\u679c\u6c47\u603b\u5230\u4e3b\u7ebf\u7a0b x\uff0c\u7531 x \u6309\u7167\u5206\u7ec4\u9879\u8fdb\u884c EP \u7ad9\u70b9\u95f4\u7684\u5206\u53d1\uff08##10\uff09\u3002\u6bcf\u4e2a EP \u7684\u4e3b\u7ebf\u7a0b x \u5728\u63a5\u6536\u5230\u5f7c\u6b64\u95f4\u53d1\u6765\u7684\u6570\u636e\u540e\uff0c\u518d\u6b21\u8fdb\u884c\u5206\u7ec4\u7684\u6700\u7ec8\u6c47\u603b\u5904\u7406\uff08##8\uff09\u3002\u63a5\u4e0b\u6765\u5904\u7406\u6392\u5e8f\uff0c\u6bcf\u4e2a\u7ebf\u7a0b\u5355\u72ec\u6392\u5e8f\uff08##7\uff09\uff0c\u6392\u5e8f\u7ed3\u679c\u4ea4\u7531\u6bcf\u4e2a EP \u7684\u4e3b\u7ebf\u7a0b\u8fdb\u884c\u6c47\u603b\uff08##6\uff09\uff0c\u8fd9\u91cc\u7684\u6c47\u603b\u7528\u5230\u4e86\u5f52\u5e76\u6392\u5e8f\u3002\u6700\u540e\u4e00\u6b65\u662f\u5404 EP \u5c06\u5f52\u5e76\u6392\u5e8f\u7ed3\u679c\u6536\u96c6\u8d77\u6765\u53d1\u9001\u7ed9\u4e3b EP\uff08##5\uff09\uff0c\u540c\u6837\uff0c\u8fd9\u91cc\u4e5f\u662f\u4e00\u4e2a\u5f52\u5e76\u6392\u5e8f\u3002<\/p>\n<h2 id=\"22-9-\u67e5\u8be2\u8ba1\u5212\u91cd\u7528\" class=\"article-heading\" style=\"position: relative;\">22.9 \u67e5\u8be2\u8ba1\u5212\u91cd\u7528<a class=\"article-anchor\" href=\"#22.9 \u67e5\u8be2\u8ba1\u5212\u91cd\u7528\" aria-hidden=\"true\"><\/a><\/p>\n<div id=\"22.9 \u67e5\u8be2\u8ba1\u5212\u91cd\u7528\" style=\"position: absolute; top: -100px;\"><\/div>\n<\/h2>\n<p>\u5982\u679c\u540c\u4e00\u6761\u8bed\u53e5\u6267\u884c\u9891\u7387\u8f83\u9ad8\uff0c\u6216\u8005\u6bcf\u6b21\u6267\u884c\u7684\u8bed\u53e5\u4ec5\u4ec5\u662f\u5e38\u91cf\u503c\u4e0d\u540c\uff0c\u5219\u53ef\u4ee5\u8003\u8651\u4f7f\u7528\u8ba1\u5212\u91cd\u7528\u673a\u5236\u3002\u907f\u514d\u6bcf\u6b21\u6267\u884c\u90fd\u9700\u8981\u4f18\u5316\u5668\u8fdb\u884c\u5206\u6790\u5904\u7406\uff0c\u53ef\u4ee5\u76f4\u63a5\u4ece\u8ba1\u5212\u7f13\u5b58\u4e2d\u83b7\u53d6\u5df2\u6709\u7684\u6267\u884c\u8ba1\u5212\uff0c\u51cf\u5c11\u4e86\u5206\u6790\u4f18\u5316\u8fc7\u7a0b\uff0c\u63d0\u9ad8\u6267\u884c\u7387\u3002<\/p>\n<p>\u5bf9\u4e8e\u8ba1\u5212\u91cd\u7528\uff0c\u8fbe\u68a6\u6570\u636e\u5e93\u63d0\u4f9b\u4e86 INI \u53c2\u6570 USE_PLN_POOL \u6765\u63a7\u5236\uff0c\u5f53\u7f6e\u4e3a\u975e 0 \u65f6\uff0c\u4f1a\u542f\u7528\u8ba1\u5212\u91cd\u7528\u3002<\/p>\n<h2 id=\"22-10-\u7ed3\u679c\u96c6\u91cd\u7528\" class=\"article-heading\" style=\"position: relative;\">22.10 \u7ed3\u679c\u96c6\u91cd\u7528<a class=\"article-anchor\" href=\"#22.10 \u7ed3\u679c\u96c6\u91cd\u7528\" aria-hidden=\"true\"><\/a><\/p>\n<div id=\"22.10 \u7ed3\u679c\u96c6\u91cd\u7528\" style=\"position: absolute; top: -100px;\"><\/div>\n<\/h2>\n<p>\u6267\u884c\u8ba1\u5212\u7684\u751f\u6210\u4e0e\u4f18\u5316\u662f\u4e00\u4e2a\u975e\u5e38\u4f9d\u8d56 CPU \u7684\u64cd\u4f5c\uff0c\u800c\u6267\u884c\u4e00\u4e2a\u67e5\u8be2\u83b7\u5f97\u7ed3\u679c\u96c6\u4e5f\u662f\u4e00\u4e2a\u975e\u5e38\u6d88\u8017\u8d44\u6e90\u7684\u64cd\u4f5c\u3002\u5f53\u7cfb\u7edf\u8fde\u7eed\u6267\u884c\u4e24\u4e2a\u5b8c\u5168\u76f8\u540c\u7684 SQL \u8bed\u53e5\uff0c\u5176\u6267\u884c\u8ba1\u5212\u548c\u7ed3\u679c\u96c6\u5f88\u6709\u53ef\u80fd\u662f\u76f8\u540c\u7684\uff0c\u5982\u679c\u91cd\u65b0\u751f\u6210\u548c\u6267\u884c\u8ba1\u5212\uff0c\u4f1a\u5927\u5927\u6d6a\u8d39\u7cfb\u7edf\u8d44\u6e90\u3002\u8fd9\u65f6\u5982\u679c\u4f7f\u7528\u8ba1\u5212\u91cd\u7528\u548c\u7ed3\u679c\u96c6\u91cd\u7528\uff0c\u7cfb\u7edf\u7684\u54cd\u5e94\u901f\u5ea6\u53ef\u4ee5\u5927\u5927\u63d0\u5347\u3002<\/p>\n<p>\u7ed3\u679c\u96c6\u91cd\u7528\u662f\u57fa\u4e8e\u8ba1\u5212\u91cd\u7528\u7684\uff0c\u5982\u679c\u67e5\u8be2\u7684\u8ba1\u5212\u4e0d\u80fd\u7f13\u5b58\uff0c\u5219\u5176\u67e5\u8be2\u7ed3\u679c\u96c6\u5fc5\u7136\u4e0d\u80fd\u7f13\u5b58\u3002\u6b64\u5916\uff0c\u5f53\u8bed\u53e5\u7684\u6e38\u6807\u5c5e\u6027\u4e3a FORWARD ONLY \u65f6\uff0c\u9ed8\u8ba4\u67e5\u8be2\u4e0d\u4f1a\u751f\u6210\u7ed3\u679c\u96c6\u3002\u800c\u53c2\u6570 BUILD_FORWARD_RS \u53ef\u4ee5\u5f3a\u5236\u5728\u6b64\u7c7b\u67e5\u8be2\u4e2d\u751f\u6210\u7ed3\u679c\u96c6\uff0c\u4ee5\u4fbf\u8fdb\u884c\u7ed3\u679c\u96c6\u91cd\u7528\u3002<\/p>\n<p>\u53ef\u901a\u8fc7\u8bbe\u7f6e INI \u53c2\u6570 RS_CAN_CACHE \u6765\u63a7\u5236\u7ed3\u679c\u96c6\u91cd\u7528\u3002\u5f53\u7f6e\u4e3a 0 \u65f6\u8868\u793a\u624b\u52a8\u6a21\u5f0f\uff08MANUAL\uff09\uff0c\u5728\u6b64\u6a21\u5f0f\u4e0b\u9ed8\u8ba4\u4e0d\u7f13\u5b58\u67e5\u8be2\u7ed3\u679c\u96c6\uff0c\u4f46\u662f DBA \u53ef\u4ee5\u901a\u8fc7\u8bed\u53e5\u63d0\u793a\u7b49\u65b9\u6cd5\u6307\u793a\u7cfb\u7edf\u5bf9\u5fc5\u8981\u7684\u67e5\u8be2\u7ed3\u679c\u96c6\u8fdb\u884c\u7f13\u5b58\uff1b\u7f6e\u4e3a 1 \u65f6\u8868\u793a\u5f3a\u5236\u6a21\u5f0f\uff08FORCE\uff09\uff0c\u5728\u6b64\u6a21\u5f0f\u4e0b\u9ed8\u8ba4\u7f13\u5b58\u6240\u6709\u53ef\u7f13\u5b58\u7ed3\u679c\u96c6\uff0c\u4f46\u662f DBA \u4e5f\u53ef\u4ee5\u901a\u8fc7\u65b0\u589e\u7684\u914d\u7f6e\u53c2\u6570\u4ee5\u53ca\u8bed\u53e5\u63d0\u793a\u7b49\u65b9\u6cd5\u53d6\u6d88\u67d0\u4e9b\u4e0d\u5408\u9002\u7684\u7ed3\u679c\u96c6\u7f13\u5b58\u3002<\/p>\n<p>\u5f53 RS_CAN_CACHE \u4e3a 1 \u65f6\uff0c\u8fd8\u53ef\u4ee5\u901a\u8fc7\u8bbe\u7f6e INI \u53c2\u6570 RS_CACHE_TABLES \u548c RS_CACHE_MIN_TIME \u5bf9\u7f13\u5b58\u7684\u7ed3\u679c\u96c6\u8fdb\u884c\u9650\u5236\u548c\u8fc7\u6ee4\u3002RS_CACHE_TABLES \u6307\u5b9a\u53ef\u4ee5\u7f13\u5b58\u7ed3\u679c\u96c6\u7684\u57fa\u8868\u6e05\u5355\uff0c\u53ea\u6709\u67e5\u8be2\u6d89\u53ca\u7684\u6240\u6709\u57fa\u8868\u5168\u90e8\u5728\u53c2\u6570\u6307\u5b9a\u8303\u56f4\u5185\uff0c\u6b64\u67e5\u8be2\u624d\u4f1a\u7f13\u5b58\u7ed3\u679c\u96c6\u3002RS_CACHE_MIN_TIME \u5219\u6307\u5b9a\u4e86\u7f13\u5b58\u7ed3\u679c\u96c6\u7684\u67e5\u8be2\u8bed\u53e5\u6267\u884c\u65f6\u95f4\u7684\u4e0b\u9650\uff0c\u53ea\u6709\u5b9e\u9645\u6267\u884c\u65f6\u95f4\u4e0d\u5c11\u4e8e\u6307\u5b9a\u503c\u7684\u67e5\u8be2\u7ed3\u679c\u96c6\u624d\u4f1a\u7f13\u5b58\u3002<\/p>\n<p>DBA \u53ef\u4ee5\u901a\u8fc7\u5728 SQL \u8bed\u53e5\u4e2d\u8bbe\u7f6e \u201cRESULT_CACHE\u201d\u6216\u201cNO_RESULT_CACHE\u201d HINT \u624b\u52a8\u6307\u793a\u67e5\u8be2\u7684\u7ed3\u679c\u96c6\u662f\u5426\u7f13\u5b58\u3002\u5982\uff1a<\/p>\n<pre><a class=\"btn-copy\" data-clipboard-target=\"\" style=\"text-align: center; float: right; margin-left: -64px; width: 64px; color: rgb(148, 163, 234); cursor: pointer; text-decoration: none; font-size: 13px; font-family: inherit; padding: 0px 0.3rem; position: relative; background: rgb(244, 244, 244); z-index: 9;\"><span>Copy<\/span><\/a><code class=\"language-plaintext hljs\" style=\"background: rgb(244, 244, 244);\">  select \/*+ RESULT_CACHE *\/ id, name from sysobjects;\n<\/code><\/pre>\n<p>\u6216\u8005<\/p>\n<pre><a class=\"btn-copy\" data-clipboard-target=\"\" style=\"text-align: center; float: right; margin-left: -64px; width: 64px; color: rgb(148, 163, 234); cursor: pointer; text-decoration: none; font-size: 13px; font-family: inherit; padding: 0px 0.3rem; position: relative; background: rgb(244, 244, 244); z-index: 9;\"><span>Copy<\/span><\/a><code class=\"language-plaintext hljs\" style=\"background: rgb(244, 244, 244);\">  select \/*+ NO_RESULT_CACHE *\/ id, name from sysobjects;\n<\/code><\/pre>\n<p>\u5728\u8bed\u53e5\u4e2d\u4f7f\u7528 HINT \u6307\u5b9a\u7ed3\u679c\u96c6\u7f13\u5b58\u7684\u4f18\u5148\u7ea7\u8981\u9ad8\u4e8e INI \u4e2d\u76f8\u5173\u53c2\u6570\u7684\u8bbe\u7f6e\u3002<\/p>\n<p>\u8fd8\u53ef\u4ee5\u4f7f\u7528\u7cfb\u7edf\u8fc7\u7a0b SP_SET_PLN_RS_CACHE \u6765\u5f3a\u5236\u8bbe\u7f6e\u6307\u5b9a\u8ba1\u5212\u7ed3\u679c\u96c6\u7f13\u5b58\u7684\u751f\u6548\u53ca\u5931\u6548\u3002\u8fd9\u4e2a\u7cfb\u7edf\u8fc7\u7a0b\u5bf9\u7ed3\u679c\u96c6\u7f13\u5b58\u7684\u6307\u5b9a\u9ad8\u4e8e\u5176\u5b83\u6240\u6709\u7ed3\u679c\u96c6\u7f13\u5b58\u7684\u8bbe\u7f6e\u3002<\/p>\n<p>\u5728\u4ee5\u4e0b\u60c5\u51b5\u4e0b\uff0cDM \u4e0d\u652f\u6301\u7ed3\u679c\u7f13\u5b58\uff1a<\/p>\n<ol>\n<li>\n<p>\u5fc5\u987b\u662f\u5355\u7eaf\u7684\u67e5\u8be2\u8bed\u53e5\u8ba1\u5212\uff0cPL \u811a\u672c\u4e2d\u5305\u542b\u67e5\u8be2\u8bed\u53e5\u4e5f\u4e0d\u80fd\u7f13\u5b58\u7ed3\u679c\u96c6\u3002<\/p>\n<\/li>\n<li>\n<p>\u67e5\u8be2\u8bed\u53e5\u7684\u8ba1\u5212\u672c\u8eab\u5fc5\u987b\u662f\u7f13\u5b58\u7684\u3002<\/p>\n<\/li>\n<li>\n<p>\u5b88\u62a4\u73af\u5883\u4e2d\u7684\u5907\u5e93\u4e0d\u652f\u6301\u7ed3\u679c\u96c6\u7f13\u5b58\u3002<\/p>\n<\/li>\n<li>\n<p>MPP \u7b49\u96c6\u7fa4\u73af\u5883\u4e0b\u4e0d\u652f\u6301\u7ed3\u679c\u96c6\u7f13\u5b58\uff083\u30014 \u4e24\u70b9\u9650\u5236\u90fd\u662f\u56e0\u4e3a\u65e0\u6cd5\u7cbe\u786e\u63a7\u5236\u57fa\u8868\u7684\u6570\u636e\u66f4\u65b0\u65f6\u6233\uff09\u3002<\/p>\n<\/li>\n<li>\n<p>\u67e5\u8be2\u8bed\u53e5\u4e2d\u5305\u542b\u4ee5\u4e0b\u4efb\u610f\u4e00\u9879\uff0c\u5176\u7ed3\u679c\u96c6\u90fd\u4e0d\u80fd\u7f13\u5b58\uff1a<\/p>\n<ol>\n<li>\u5305\u542b\u4e34\u65f6\u8868\uff1b<\/li>\n<li>\u5305\u542b\u5e8f\u5217\u7684 CURVAL \u6216 NEXTVAL\uff1b<\/li>\n<li>\u5305\u542b\u975e\u786e\u5b9a\u7684 SQL \u51fd\u6570\u6216\u5305\u65b9\u6cd5\uff08\u73b0\u6709\u903b\u8f91\u662f\u4e0d\u652f\u6301\u6240\u6709 SQL \u51fd\u6570\u6216\u5305\u65b9\u6cd5\uff09\uff1b<\/li>\n<li>\u5305\u542b RAND\u3001SYSDATE \u7b49\u8fd4\u56de\u503c\u5b9e\u65f6\u53d8\u5316\u7684\u7cfb\u7edf\u51fd\u6570\uff1b<\/li>\n<li>\u5305\u542b\u5176\u5b83\u7684\u4e00\u4e9b\u5b9e\u65f6\u8981\u7d20\u3002<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u6570\u636e\u5e93\u6267\u884c\u4e00\u6761\u8bed\u53e5\u6709\u591a\u79cd\u65b9\u5f0f\uff0c\u4e3a\u4e86\u9009\u62e9\u6700\u4f18\u7684\u6267\u884c\u65b9\u5f0f\uff0c\u4ea7\u751f\u4e86\u67e5\u8be2\u4f18\u5316\u5668\u3002\u67e5\u8be2\u4f18\u5316\u5668\u5206\u6790\u8bed\u53e5\u8fd0\u884c\u65f6\u7684\u6240\u6709\u56e0\u7d20\uff0c\u9009\u62e9\u6700\u4f18\u7684\u65b9\u5f0f\u53bb\u6267\u884c\uff0c\u63d0\u9ad8\u4e86\u67e5\u8be2\u6548\u7387\u3002\u56e0\u6b64\uff0c\u67e5\u8be2\u4f18\u5316\u662f\u6570\u636e\u5e93\u6267\u884c SQL \u8bed\u53e5\u7684\u91cd\u8981\u8fc7\u7a0b\uff0c\u51b3\u5b9a\u4e86\u6570\u636e\u5e93\u7684\u67e5\u8be2\u6027\u80fd\u3002 22.1 \u4f18\u5316\u76ee\u6807 \u8fbe\u68a6\u6570\u636e\u5e93\u67e5\u8be2\u4f18\u5316\u5668\u7684\u4f18\u5316\u76ee\u6807\u4e3a\u6700\u5feb\u54cd\u5e94\u65f6\u95f4\u3002\u901a\u8fc7\u8bbe\u7f6e\u53c2\u6570 FIRST_ROWS \u6765\u51b3\u5b9a\u4f18\u5148\u8fd4\u56de\u591a\u5c11\u6761\u8bb0\u5f55\u7ed9\u7528\u6237\uff0c\u800c\u4e0d\u9700\u8981\u7b49\u5f85\u5168\u90e8\u7ed3\u679c\u786e\u5b9a\u540e\u518d\u8f93\u51fa\uff0cFIRST_ROWS \u8bbe\u7f6e\u8303\u56f4\u4e3a 1~1000\uff0c\u5355\u4f4d\u4e3a\u884c\u3002\u4f8b\u5982\uff1aFIRST_ROWS = 10\uff0c\u610f\u601d\u662f\u67e5\u8be2\u51fa 10 \u6761\u7ed3\u679c\u5c31\u7acb\u5373\u8fd4\u56de\u7ed9\u7528\u6237\u3002\u53ef\u4ee5\u6839\u636e\u5b9e\u9645\u60c5\u51b5\uff0c\u8c03\u6574\u53c2\u6570\u503c\u3002 22.2 \u67e5\u8be2\u4f18\u5316\u5668 \u67e5\u8be2\u4f18\u5316\u5668\u901a\u8fc7\u5206\u6790\u53ef\u7528\u7684\u6267\u884c\u65b9\u5f0f\u548c\u67e5\u8be2\u6240\u6d89\u53ca\u7684\u5bf9\u8c61\u7edf\u8ba1\u4fe1\u606f\u6765\u751f\u6210\u6700\u4f18\u7684\u6267\u884c\u8ba1\u5212\u3002\u6b64\u5916\uff0c\u5982\u679c\u5b58\u5728 HINT \u4f18\u5316\u63d0\u793a\uff0c\u4f18\u5316\u5668\u8fd8\u9700\u8981\u8003\u8651\u4f18\u5316\u63d0\u793a\u7684\u56e0\u7d20\u3002 \u67e5\u8be2\u4f18\u5316\u5668\u7684\u5904\u7406\u8fc7\u7a0b\u5305\u62ec\uff1a \u4f18\u5316\u5668\u751f\u6210\u6240\u6709\u53ef\u80fd\u7684\u6267\u884c\u8ba1\u5212\u96c6\u5408\uff1b \u4f18\u5316\u5668\u57fa\u4e8e\u5b57\u5178\u4fe1\u606f\u7684\u6570\u636e\u5206\u5e03\u7edf\u8ba1\u503c\u3001\u6267\u884c\u8bed\u53e5\u6d89\u53ca\u5230\u7684\u8868\u3001\u7d22\u5f15\u548c\u5206\u533a\u7684\u5b58\u50a8\u7279\u70b9\u6765\u4f30\u7b97\u6bcf\u4e2a\u6267\u884c\u8ba1\u5212\u7684\u4ee3\u4ef7\u3002\u4ee3\u4ef7\u662f\u6307 SQL \u8bed\u53e5\u4f7f\u7528\u67d0\u79cd\u6267\u884c\u65b9\u5f0f\u6240\u6d88\u8017\u7684\u7cfb\u7edf\u8d44\u6e90\u7684\u4f30\u7b97\u503c\u3002\u5176\u4e2d\uff0c\u7cfb\u7edf\u8d44\u6e90\u6d88\u8017\u5305\u62ec I\/O\u3001CPU \u4f7f\u7528\u60c5\u51b5\u3001\u5185\u5b58\u6d88\u8017\u7b49\uff1b \u4f18\u5316\u5668\u9009\u62e9\u4ee3\u4ef7\u6700\u5c0f\u7684\u6267\u884c\u65b9\u5f0f\u4f5c\u4e3a\u8be5\u6761\u8bed\u53e5\u7684\u6700\u7ec8\u6267\u884c\u8ba1\u5212\u3002 \u4f18\u5316\u5668\u6240\u505a\u7684\u64cd\u4f5c\u6709\uff1a\u67e5\u8be2\u8f6c\u6362\u3001\u4f30\u7b97\u4ee3\u4ef7\u3001\u751f\u6210\u8ba1\u5212\u3002 22.2.1 \u67e5\u8be2\u8f6c\u6362 \u67e5\u8be2\u8f6c\u6362\u662f\u6307\u628a\u7ecf\u8fc7\u8bed\u6cd5\u3001\u8bed\u4e49\u5206\u6790\u7684\u67e5\u8be2\u5757\u4e4b\u95f4\u7684\u8fde\u63a5\u7c7b\u578b\u3001\u5d4c\u5957\u5173\u7cfb\u8fdb\u884c\u8c03\u6574\uff0c\u751f\u6210\u4e00\u4e2a\u66f4\u597d\u7684\u67e5\u8be2\u8ba1\u5212\u3002\u5e38\u7528\u7684\u67e5\u8be2\u8f6c\u6362\u6280\u672f\u5305\u62ec\u8fc7\u6ee4\u6761\u4ef6\u7684\u4e0b\u653e\u3001\u76f8\u5173\u5b50\u67e5\u8be2\u7684\u53bb\u76f8\u5173\u6027\u3002 \u8fc7\u6ee4\u6761\u4ef6\u4e0b\u653e\uff1a\u5728\u8fde\u63a5\u67e5\u8be2\u4e2d\uff0c\u628a\u90e8\u5206\u8868\u7684\u8fc7\u6ee4\u6761\u4ef6\u4e0b\u79fb\uff0c\u5728\u8fde\u63a5\u4e4b\u524d\u5148\u8fc7\u6ee4\uff0c\u53ef\u4ee5\u51cf\u5c11\u8fde\u63a5\u64cd\u4f5c\u7684\u6570\u636e\u91cf\uff0c\u63d0\u5347\u8bed\u53e5\u6027\u80fd\uff1b \u76f8\u5173\u5b50\u67e5\u8be2\u7684\u53bb\u76f8\u5173\u6027\uff1a\u628a\u4e0e\u5b50\u67e5\u8be2\u76f8\u5173\u7684\u5916\u8868\u4e0e\u5185\u8868\u91c7\u7528\u534a\u8fde\u63a5\u7684\u65b9\u5f0f\u6267\u884c\uff0c\u653e\u5f03\u9ed8\u8ba4\u91c7\u53d6\u7684\u5d4c\u5957\u8fde\u63a5\u65b9\u5f0f\uff0c\u5bf9\u6027\u80fd\u6709\u8f83\u5927\u63d0\u5347\u3002 22.2.2 \u4f30\u7b97\u4ee3\u4ef7 \u4f30\u7b97\u4ee3\u4ef7\u662f\u6307\u5bf9\u6267\u884c\u8ba1\u5212\u7684\u6210\u672c\u8fdb\u884c\u4f30\u7b97\u3002\u6267\u884c\u8282\u70b9\u4e4b\u95f4\u7684\u4ee3\u4ef7\u503c\u76f8\u5173\u6027\u8f83\u5f3a\uff0c\u4e00\u4e2a\u6267\u884c\u8282\u70b9\u7684\u4ee3\u4ef7\u5305\u62ec\u8be5\u8282\u70b9\u5305\u542b\u7684\u5b50\u8282\u70b9\u4ee3\u4ef7\u3002\u4ee3\u4ef7\u8861\u91cf\u6307\u6807\u5305\u62ec\u9009\u62e9\u7387\u3001\u57fa\u6570\u3001\u4ee3\u4ef7\u3002 \u9009\u62e9\u7387\u662f\u6307\u6ee1\u8db3\u6761\u4ef6\u7684\u8bb0\u5f55\u5360\u603b\u8bb0\u5f55\u6570\u7684\u767e\u5206\u6bd4\u3002\u8bb0\u5f55\u96c6\u53ef\u4ee5\u662f\u57fa\u8868\u3001\u89c6\u56fe\u3001\u8fde\u63a5\u6216\u5206\u7ec4\u64cd\u4f5c\u7684\u7ed3\u679c\u96c6\u3002\u9009\u62e9\u7387\u548c\u67e5\u8be2\u8c13\u8bcd\u76f8\u5173\uff0c\u5982 name = \u2018\u97e9\u6885\u6885\u2019\uff1b\u6216\u8005\u662f\u8c13\u8bcd\u7684\u8fde\u63a5\uff0c\u5982 name =\u2018\u97e9\u6885\u6885\u2019 and no =\u20180123\u2019\u3002\u4e00\u4e2a\u8c13\u8bcd\u53ef\u4ee5\u770b\u4f5c\u662f\u4e00\u4e2a\u8fc7\u6ee4\u5668\uff0c\u8fc7\u6ee4\u6389\u7ed3\u679c\u96c6\u4e2d\u4e0d\u6ee1\u8db3\u6761\u4ef6\u7684\u8bb0\u5f55\u3002\u9009\u62e9\u7387\u7684\u8303\u56f4\u4ece 0 \u5230 1\u3002\u5176\u4e2d\uff0c0 \u8868\u793a\u6ca1\u6709\u8bb0\u5f55\u88ab\u9009\u4e2d\uff0c1 \u8868\u793a\u884c\u96c6\u4e2d\u6240\u6709\u8bb0\u5f55\u90fd\u88ab\u9009\u4e2d\u3002 \u5982\u679c\u6ca1\u6709\u7edf\u8ba1\u4fe1\u606f\uff0c\u5219\u4f18\u5316\u5668\u4f9d\u636e\u8fc7\u6ee4\u6761\u4ef6\u7684\u7c7b\u578b\u6765\u8bbe\u7f6e\u5bf9\u5e94\u7684\u9009\u62e9\u7387\u3002\u4f8b\u5982\uff0c\u7b49\u503c\u6761\u4ef6\u7684\u9009\u62e9\u7387\u4f4e\u4e8e\u8303\u56f4\u6761\u4ef6\u9009\u62e9\u7387\u3002\u8fd9\u4e9b\u5047\u5b9a\u662f\u6839\u636e\u7ecf\u9a8c\u503c\uff0c\u8ba4\u4e3a\u7b49\u503c\u6761\u4ef6\u8fd4\u56de\u7684\u7ed3\u679c\u96c6\u6700\u5c11\u3002 \u5982\u679c\u6709\u7edf\u8ba1\u4fe1\u606f\uff0c\u5219\u53ef\u4ee5\u4f7f\u7528\u7edf\u8ba1\u4fe1\u606f\u6765\u4f30\u7b97\u9009\u62e9\u7387\u3002\u4f8b\u5982\uff0c\u5bf9\u4e8e\u7b49\u503c\u8c13\u8bcd\uff08name =\u2018\u97e9\u6885\u6885\u2019\uff09\uff0c\u5982\u679c name \u5217\u6709 N \u4e2a\u4e0d\u540c\u503c\uff0c\u90a3\u4e48\uff0c\u9009\u62e9\u7387\u662f N \u5206\u4e4b\u4e00\u3002 \u57fa\u6570\u662f\u6307\u6574\u4e2a\u884c\u96c6\u7684\u884c\u6570\uff0c\u8be5\u884c\u96c6\u53ef\u4ee5\u662f\u57fa\u8868\u3001\u89c6\u56fe\u3001\u8fde\u63a5\u6216\u5206\u7ec4\u64cd\u4f5c\u7684\u7ed3\u679c\u96c6\u3002 \u4ee3\u4ef7\u8868\u793a\u8d44\u6e90\u7684\u4f7f\u7528\u60c5\u51b5\u3002\u67e5\u8be2\u4f18\u5316\u5668\u4f7f\u7528\u78c1\u76d8 I\/O\u3001CPU \u5360\u7528\u548c\u5185\u5b58\u4f7f\u7528\u4f5c\u4e3a\u4ee3\u4ef7\u8ba1\u7b97\u7684\u4f9d\u636e\uff0c\u6240\u4ee5\u4ee3\u4ef7\u53ef\u4ee5\u7528 I\/O \u6570\u3001CPU \u4f7f\u7528\u7387\u548c\u5185\u5b58\u4f7f\u7528\u4e00\u7ec4\u503c\u6765\u8868\u793a\u3002\u6240\u6709\u64cd\u4f5c\u90fd\u53ef\u4ee5\u8fdb\u884c\u4ee3\u4ef7\u8ba1\u7b97\uff0c\u4f8b\u5982\u626b\u63cf\u57fa\u8868\u3001\u7d22\u5f15\u626b\u63cf\u3001\u8fde\u63a5\u64cd\u4f5c\u6216\u8005\u5bf9\u7ed3\u679c\u96c6\u6392\u5e8f\u7b49\u3002 \u8bbf\u95ee\u8def\u5f84\u51b3\u5b9a\u4e86\u4ece\u4e00\u4e2a\u57fa\u8868\u4e2d\u83b7\u53d6\u6570\u636e\u6240\u9700\u8981\u7684\u4ee3\u4ef7\u3002\u8bbf\u95ee\u8def\u5f84\u53ef\u4ee5\u662f\u57fa\u8868\u626b\u63cf\u3001\u7d22\u5f15\u626b\u63cf\u7b49\u3002\u5728\u8fdb\u884c\u57fa\u8868\u626b\u63cf\u6216\u7d22\u5f15\u626b\u63cf\u65f6\uff0c\u4e00\u6b21 I\/O \u8bfb\u591a\u4e2a\u9875\uff0c\u6240\u4ee5\uff0c\u57fa\u8868\u626b\u63cf\u6216\u7d22\u5f15\u5168\u626b\u63cf\u7684\u4ee3\u4ef7\u4f9d\u8d56\u4e8e\u8868\u7684\u6570\u636e\u9875\u6570\u548c\u591a\u9875\u8bfb\u7684\u53c2\u6570\u503c\u3002\u4e8c\u7ea7\u7d22\u5f15\u626b\u63cf\u7684\u4ee3\u4ef7\u4f9d\u8d56\u4e8e B \u6811\u7684\u5c42\u6b21\u3001\u9700\u626b\u63cf\u7684\u53f6\u5b50\u5757\u6811\u4ee5\u53ca\u6839\u636e rowid \u8bbf\u95ee\u805a\u96c6\u7d22\u5f15\u7684\u8bb0\u5f55\u6570\u3002 \u8fde\u63a5\u4ee3\u4ef7\u662f\u6307\u8bbf\u95ee\u4e24\u4e2a\u8fde\u63a5\u7684\u7ed3\u679c\u96c6\u4ee3\u4ef7\u4e0e\u8fde\u63a5\u64cd\u4f5c\u7684\u4ee3\u4ef7\u4e4b\u548c\u3002 22.2.3 \u751f\u6210\u8ba1\u5212 \u751f\u6210\u8ba1\u5212\u6307\u8ba1\u5212\u751f\u6210\u5668\u5bf9\u7ed9\u5b9a\u7684\u67e5\u8be2\u6309\u7167\u8fde\u63a5\u65b9\u5f0f\u3001\u8fde\u63a5\u987a\u5e8f\u3001\u8bbf\u95ee\u8def\u5f84\u751f\u6210\u4e0d\u540c\u7684\u6267\u884c\u8ba1\u5212\uff0c\u9009\u62e9\u4ee3\u4ef7\u6700\u5c0f\u7684\u4e00\u4e2a\u4f5c\u4e3a\u6700\u7ec8\u7684\u6267\u884c\u8ba1\u5212\u3002 \u8fde\u63a5\u987a\u5e8f\u6307\u4e0d\u540c\u8fde\u63a5\u9879\u7684\u5904\u7406\u987a\u5e8f\u3002\u8fde\u63a5\u9879\u53ef\u4ee5\u662f\u57fa\u8868\u3001\u89c6\u56fe\u3001\u6216\u8005\u662f\u4e00\u4e2a\u4e2d\u95f4\u7ed3\u679c\u96c6\u3002\u4f8b\u5982\u8868 t1\u3001t2\u3001t3 \u7684\u8fde\u63a5\u987a\u5e8f\u662f\u5148\u8bbf\u95ee t1\uff0c\u518d\u8bbf\u95ee t2\uff0c\u7136\u540e\u5bf9 t1 \u4e0e t2 \u505a\u8fde\u63a5\u751f\u6210\u7ed3\u679c\u96c6 r1\uff0c\u6700\u540e\u628a t3 \u4e0e r1 \u505a\u8fde\u63a5\u3002\u4e00\u4e2a\u67e5\u8be2\u8bed\u53e5\u53ef\u80fd\u7684\u8ba1\u5212\u6570\u91cf\u662f\u4e0e FROM \u8bed\u53e5\u4e2d\u8fde\u63a5\u9879\u7684\u6570\u91cf\u6210\u6b63\u6bd4\u7684\uff0c\u968f\u7740\u8fde\u63a5\u9879\u7684\u6570\u91cf\u589e\u52a0\u800c\u589e\u52a0\u3002 22.3 \u6570\u636e\u8bbf\u95ee\u8def\u5f84 \u8bbf\u95ee\u8def\u5f84\u6307\u4ece\u6570\u636e\u5e93\u4e2d\u68c0\u7d22\u6570\u636e\u7684\u65b9\u6cd5\u3002\u4e00\u822c\u60c5\u51b5\u4e0b\uff0c\u7d22\u5f15\u8bbf\u95ee\u7528\u4e8e\u68c0\u7d22\u8868\u7684\u5c0f\u90e8\u5206\u6570\u636e\uff0c\u5168\u8868\u626b\u63cf\u7528\u4e8e\u8bbf\u95ee\u8868\u7684\u5927\u90e8\u5206\u6570\u636e\u3002OLTP \u5e94\u7528\u4e2d\uff0c\u4e00\u822c\u4f7f\u7528\u7d22\u5f15\u8bbf\u95ee\u8def\u5f84\uff0c\u56e0\u4e3a OLTP \u4e2d\u5305\u542b\u4e86\u8bb8\u591a\u9ad8\u9009\u62e9\u7387\u7684 SQL \u8bed\u53e5\u3002\u800c\u51b3\u7b56\u652f\u6301\u7cfb\u7edf\u5219\u503e\u5411\u4e8e\u6267\u884c\u5168\u8868\u626b\u63cf\u6765\u83b7\u53d6\u6570\u636e\u3002\u4ece\u6570\u636e\u5e93\u4e2d\u5b9a\u4f4d\u548c\u68c0\u7d22\u6570\u636e\u7684\u65b9\u6cd5\u6709\uff1a\u5168\u8868\u626b\u63cf\u3001\u805a\u96c6\u7d22\u5f15\u626b\u63cf\u3001\u4e8c\u7ea7\u7d22\u5f15\u626b\u63cf\u7b49\u3002 \u5168\u8868\u626b\u63cf\u662f\u6307\u4ece\u57fa\u8868\u4e2d\u68c0\u7d22\u6570\u636e\u65f6\uff0c\u626b\u63cf\u8be5\u8868\u4e2d\u6240\u6709\u7684\u6570\u636e\u3002\u5168\u8868\u626b\u63cf\u65b9\u5f0f\u9002&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_eb_attr":"","footnotes":""},"categories":[101,80],"tags":[],"class_list":["post-2072","post","type-post","status-publish","format-standard","hentry","category-101","category-80"],"_links":{"self":[{"href":"https:\/\/oneai.eu.org\/index.php?rest_route=\/wp\/v2\/posts\/2072","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/oneai.eu.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/oneai.eu.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/oneai.eu.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/oneai.eu.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2072"}],"version-history":[{"count":1,"href":"https:\/\/oneai.eu.org\/index.php?rest_route=\/wp\/v2\/posts\/2072\/revisions"}],"predecessor-version":[{"id":2073,"href":"https:\/\/oneai.eu.org\/index.php?rest_route=\/wp\/v2\/posts\/2072\/revisions\/2073"}],"wp:attachment":[{"href":"https:\/\/oneai.eu.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2072"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/oneai.eu.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2072"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/oneai.eu.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2072"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}