{"id":91143,"date":"2026-08-07T02:17:14","date_gmt":"2026-08-06T18:17:14","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/91143.html"},"modified":"2026-08-07T02:17:14","modified_gmt":"2026-08-06T18:17:14","slug":"hive-on-spark-%e4%bc%81%e4%b8%9a%e7%ba%a7%e8%b0%83%e4%bc%98%ef%bc%88%e4%ba%8c%ef%bc%89sql-%e4%bc%98%e5%8c%96%ef%bc%88%e4%b8%8a%ef%bc%89%ef%bc%9a%e6%89%a7%e8%a1%8c%e8%ae%a1%e5%88%92%e4%b8%8e%e5%b8%b8","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/91143.html","title":{"rendered":"Hive on Spark \u4f01\u4e1a\u7ea7\u8c03\u4f18\uff08\u4e8c\uff09SQL \u4f18\u5316\uff08\u4e0a\uff09\uff1a\u6267\u884c\u8ba1\u5212\u4e0e\u5e38\u89c4\u4f18\u5316"},"content":{"rendered":"<p>\u4e0a\u4e00\u7bc7\u6211\u4eec\u628a\u96c6\u7fa4\u548c\u5f15\u64ce\u7684&#034;\u786c\u4ef6\u5e95\u5ea7&#034;\u914d\u597d\u4e86\u2014\u2014\u8f66\u9053\u4fee\u5bbd\u3001\u9650\u901f\u8bbe\u5bf9\u3002\u8fd9\u4e00\u7bc7\u5f00\u59cb\u770b\u8f66\u600e\u4e48\u5f00&#xff1a;\u4e00\u6761 SQL \u8fdb\u53bb&#xff0c;Hive \u5148\u628a\u5b83\u62c6\u6210 Stage \u548c Operator&#xff08;\u7b2c 4 \u7ae0&#xff09;&#xff0c;\u7136\u540e\u6211\u4eec\u9010\u4e2a\u73af\u8282\u62a0\u6027\u80fd\u2014\u2014\u805a\u5408\u3001\u88c1\u526a\u3001Join\u3001\u5c0f\u6587\u4ef6\u3001\u5e76\u884c\u5ea6\u3001CBO\u3002\u53c2\u6570\u90fd\u7ed9\u4f60&#xff0c;\u4f46\u66f4\u91cd\u8981\u7684\u662f\u544a\u8bc9\u4f60\u6bcf\u4e2a\u53c2\u6570\u5728\u89e3\u51b3\u6267\u884c\u8ba1\u5212\u91cc\u7684\u54ea\u4e00\u6bb5\u74f6\u9888\u3002<\/p>\n<h2>4. Hive SQL \u6267\u884c\u8ba1\u5212<\/h2>\n<p>\u200b\u4f7f\u7528Explain\u53ef\u4ee5\u67e5\u770b Hive SQL \u7684\u6267\u884c\u8ba1\u5212<\/p>\n<p>\u200bExplain \u67e5\u770b\u7684\u6267\u884c\u8ba1\u5212&#xff0c;\u6709\u4e00\u7cfb\u5217\u7684Stage&#xff08;\u8fd9\u662f Hive \u4e2d\u7684 Stage&#xff0c; \u8ddf Spark \u7684 Stage \u4e0d\u662f\u4e00\u56de\u4e8b&#xff09;\u7ec4\u6210&#xff0c;\u8fd9\u4e2a Stage \u5177\u6709\u4f9d\u8d56\u5173\u7cfb&#xff0c;\u6bcf\u4e2a Stage \u5bf9\u5e94\u4e00\u4e2a MR Job \u6216\u8005 Spark Job&#xff0c;\u6216\u8005\u4e00\u4e2a\u6587\u4ef6\u7cfb\u7edf\u64cd\u4f5c&#xff08; load \u8bed\u53e5&#xff09;\u7b49\u3002<\/p>\n<p>\u200b\u6bcf\u4e00\u4e2a Stage \u7531\u4e00\u7cfb\u5217\u7684 Operator \u7ec4\u6210&#xff0c;\u4e00\u4e2a Operator \u4ee3\u8868\u4e00\u4e2a\u903b\u8f91\u8349\u9519&#xff0c;\u4f8b\u5982&#xff1a;TableScan Operator&#xff0c; Select Operator,&#xff0c;Join Operator&#xff0c;Groupby Operator\u7b49\u3002<\/p>\n<p>\u200bStage \u4e0e Operator \u7684\u5bf9\u5e94\u5173\u7cfb&#xff1a;<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260806181707-6a74cfa3e1ab7.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h2>5. \u5206\u7ec4\u805a\u5408\u4f18\u5316&#xff08;map-side&#xff09;<\/h2>\n<p>\u4ee5\u8fd9\u6761\u7b80\u5355SQL\u8bed\u53e5\u4e3a\u4f8b&#xff1a;<\/p>\n<p>hive&gt;<br \/>\nselect<br \/>\n    user_id,<br \/>\n    count(*)<br \/>\nfrom dwd_user_login_inc<br \/>\nwhere dt &#061; &#039;2022-07-01&#039;<br \/>\ngroup by user_id;<\/p>\n<h3>5.1 \u4f18\u5316\u524d\u6267\u884c\u8ba1\u5212<\/h3>\n<p>\u53ef\u4ee5\u4f7f\u7528 Explain \u67e5\u770b\u6267\u884c\u8ba1\u5212&#xff0c;explain &#043; \u6267\u884cSQL&#xff1b;<\/p>\n<p>\u5173\u7cfb\u5982\u4e0b&#xff1a;<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260806181708-6a74cfa4c7744.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u5f53\u6570\u636e\u91cf\u5de8\u5927\u65f6&#xff0c;Shuffle \u6210\u4e3a\u6700\u5927\u7684\u6027\u80fd\u74f6\u9888\u2014\u2014\u6d89\u53ca\u78c1\u76d8 I\/O\u3001\u7f51\u7edc\u4f20\u8f93\u3001\u5e8f\u5217\u5316\/\u53cd\u5e8f\u5217\u5316\u3002<\/p>\n<h3>5.2 \u4f18\u5316\u601d\u8def\u4e0e\u53c2\u6570\u8bbe\u7f6e<\/h3>\n<p>\u200b\u5728\u8fd9\u5206\u7ec4\u805a\u5408\u7684\u8fc7\u7a0b\u4e2d&#xff0c;\u5f71\u54cd\u6700\u5927\u7684\u5c31\u662f Shuffle \u9636\u6bb5&#xff0c;Shuffle \u9636\u6bb5\u9700\u8981\u8bfb\u5199\u78c1\u76d8&#xff0c;\u901f\u5ea6\u6162\u3002\u8868\u7684 Size \u8d8a\u5927&#xff0c;\u6536\u5230\u7684\u5f71\u54cd\u8d8a\u6df1\u3002\u6240\u4ee5\u6211\u4eec\u53ef\u4ee5\u5f00\u542f\u5206\u7ec4\u9884\u5148\u805a\u5408&#xff0c;\u5728 Map 1 \u4e2d\u5c31\u63d0\u524d\u5148\u805a\u5408&#xff0c;\u51cf\u5c11\u5230Shuffle\u9636\u6bb5\u7684\u6570\u636e\u91cf\u3002<\/p>\n<p>\u200b\u4f18\u5316\u601d\u8def\u4e3a map-side \u805a\u5408\u3002\u5728 map \u7aef\u7ef4\u62a4\u4e00\u4e2a hash table&#xff0c;\u5229\u7528 hash table \u5b8c\u6210\u90e8\u5206\u7684\u805a\u5408&#xff0c;\u7136\u540e\u5c06\u8fd9\u90e8\u5206\u805a\u5408\u7684\u7ed3\u679c\u7ecf\u8fc7 shuffle \u53d1\u9001\u5230 reduce \u7aef&#xff0c;\u5b8c\u6210\u6700\u7ec8\u7684\u805a\u5408\u3002 map-side \u805a\u5408\u80fd\u6709\u6548\u51cf\u5c11 shuffle \u7684\u6570\u636e\u91cf&#xff0c;\u63d0\u9ad8 \u5206\u7ec4\u805a\u5408 \u7684\u6548\u7387\u3002<\/p>\n<p>\u200bmap-side \u76f8\u5173\u7684\u53c2\u6570\u5982\u4e0b&#xff1a;<\/p>\n<p># \u662f\u5426\u5728 Map \u7aef\u8fdb\u884c\u805a\u5408&#xff0c;\u9ed8\u8ba4 true<br \/>\nhive.map.aggr &#061; true;<br \/>\n# hash table \u5360 map \u7aef\u5185\u5b58\u7684\u5927\u5c0f&#xff0c;\u9ed8\u8ba4 0.5<br \/>\nhive.map.aggr.hash.percentmemory &#061; 0.5;<br \/>\n# Map \u7aef\u805a\u5408\u540e\u7684\u6570\u636e\u91cf \/ \u539f\u59cb\u6570\u636e\u91cf\u7684\u6bd4\u503c&#xff0c;\u82e5\u5927\u4e8e\u6b64\u503c\u5219\u5173\u95ed Map \u7aef\u805a\u5408&#xff08;\u8ba4\u4e3a\u805a\u5408\u6548\u679c\u4e0d\u597d&#xff09;<br \/>\nhive.map.aggr.hash.min.reduction &#061; 0.5; \u9ed8\u8ba4 0.5<br \/>\n# \u54c8\u5e0c\u8868\u5185\u5b58\u4f7f\u7528\u8fbe\u5230\u6b64\u503c\u65f6\u5f3a\u5236\u5237\u5199,\u9ed8\u8ba4\u503c 0.9<br \/>\nhive.map.aggr.hash.force.flush.memory.threshold &#061; 0.9<br \/>\n# \u6570\u636e\u503e\u659c\u5f0f\u662f\u5426\u542f\u7528\u4e24\u9636\u6bb5\u805a\u5408&#xff08;\u8be6\u89c1\u540e\u7eed\u6570\u636e\u503e\u659c\u7ae0\u8282&#xff09;&#xff0c;\u9ed8\u8ba4 false<br \/>\nhive.groupby.skewindata &#061; false<\/p>\n<h3>5.3 \u4f18\u5316\u540e\u7684\u6267\u884c\u8ba1\u5212<\/h3>\n<p>\u200bExplain\u6267\u884c\u8ba1\u5212<\/p>\n<p>\u793a\u610f\u56fe&#xff1a;<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260806181709-6a74cfa5a3a2d.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h3>5.4 \u6267\u884c\u524d\u540e\u5bf9\u6bd4<\/h3>\n<p>\u5982\u679c\u57fa\u4e8e Snappy \u538b\u7f29\u65b9\u5f0f\u7684\u8868&#xff0c;\u4e00\u4e2a\u5206\u533a\u4e2d\u7684\u6570\u636e\u843d\u76d8\u5927\u6982 4G &#xff0c;\u5728\u5185\u5b58\u4e2d\u8fd0\u7b97\u5927\u6982 15G&#xff1a;<\/p>\n<ul>\n<li>\u6ca1\u6709\u4f18\u5316\u4e4b\u524d&#xff0c;\u6267\u884c\u8fd9\u4e2a Hive SQL \u9700\u8981\u5927\u6982 36s \u5de6\u53f3<\/li>\n<li>\u5f00\u542f map-side \u4f18\u5316\u4e4b\u540e&#xff0c;\u6267\u884c Hive SQL \u5927\u7ea6\u5728 6s-8s&#xff0c;\u5927\u5927\u7684\u63d0\u9ad8\u4e86\u6267\u884c\u901f\u5ea6<\/li>\n<\/ul>\n<h2>6. \u5206\u533a\u88c1\u526a &amp; \u5217\u88c1\u526a<\/h2>\n<h3>6.1 \u5206\u533a\u88c1\u526a<\/h3>\n<p>&#8212; \u274c \u5168\u8868\u626b\u63cf&#xff08;\u626b\u63cf\u6240\u6709\u5206\u533a&#xff09;<br \/>\nSELECT * FROM orders WHERE SUBSTR(order_time, 1, 10) &#061; &#039;2026-07-25&#039;;<\/p>\n<p>&#8212; \u2705 \u5206\u533a\u88c1\u526a&#xff08;\u53ea\u626b\u63cf\u76ee\u6807\u5206\u533a&#xff09;<br \/>\nSELECT * FROM orders WHERE dt &#061; &#039;2026-07-25&#039;;<\/p>\n<p>&#8212; \u2705 \u591a\u5206\u533a\u8303\u56f4<br \/>\nSELECT * FROM orders WHERE dt BETWEEN &#039;2026-07-01&#039; AND &#039;2026-07-25&#039;;<\/p>\n<p>&#8212; \u2705 \u52a8\u6001\u5206\u533a\u88c1\u526a&#xff08;Spark 3.0&#043;&#xff09;<br \/>\nSET spark.sql.optimizer.dynamicPartitionPruning.enabled &#061; true;<\/p>\n<p>SELECT o.*, u.user_name<br \/>\nFROM orders o<br \/>\nJOIN users u ON o.user_id &#061; u.user_id<br \/>\nWHERE u.city &#061; &#039;\u5317\u4eac&#039;;  &#8212; \u81ea\u52a8\u88c1\u526a\u975e\u5317\u4eac\u5206\u533a<\/p>\n<h3>6.2 \u5217\u88c1\u526a<\/h3>\n<p>&#8212; \u274c \u8bfb\u53d6\u6240\u6709\u5217&#xff08;ORC\/Parquet\u662f\u5217\u5b58&#xff0c;\u8bfb\u6240\u6709\u5217&#061;\u5168\u91cfI\/O&#xff09;<br \/>\nSELECT * FROM orders WHERE dt &#061; &#039;2026-07-25&#039;;<\/p>\n<p>&#8212; \u2705 \u53ea\u8bfb\u9700\u8981\u7684\u5217<br \/>\nSELECT order_id, user_id, amount FROM orders WHERE dt &#061; &#039;2026-07-25&#039;;<\/p>\n<h2>7. \u8c13\u8bcd\u4e0b\u63a8(Predicate Pushdown)<\/h2>\n<p>\u200b\u8c13\u8bcd\u4e0b\u63a8&#xff1a;\u5c06\u8fc7\u6ee4\u6761\u4ef6\u4ece\u6267\u884c\u8ba1\u5212\u7684\u4e0a\u5c42\u79fb\u52a8\u5230\u4e0b\u5c42&#xff08;\u66f4\u9760\u8fd1\u6570\u636e\u6e90\u7684\u4f4d\u7f6e&#xff09;&#xff0c;\u4f7f\u5f97&#xff1a;\u5728\u6570\u636e\u88ab\u8bfb\u53d6\u3001\u4f20\u8f93\u3001\u8ba1\u7b97\u4e4b\u524d&#xff0c;\u5c31\u5c3d\u65e9\u5730\u4e22\u5f03\u4e0d\u9700\u8981\u7684\u6570\u636e\u3002<\/p>\n<p>&#8212; \u5f00\u542f\u8c13\u8bcd\u4e0b\u63a8&#xff08;\u5c06WHERE\u6761\u4ef6\u4e0b\u63a8\u5230\u5b58\u50a8\u5c42\u8fc7\u6ee4&#xff09;<br \/>\nSET hive.optimize.ppd &#061; true;<br \/>\nSET hive.optimize.ppd.storage &#061; true;<\/p>\n<p>&#8212; ORC\/Parquet \u6587\u4ef6\u4f1a\u5229\u7528 Row Group \u7684 min\/max \u7edf\u8ba1\u4fe1\u606f\u8df3\u8fc7\u4e0d\u76f8\u5173\u6570\u636e\u5757<br \/>\nSELECT order_id, amount<br \/>\nFROM orders<br \/>\nWHERE dt &#061; &#039;2026-07-25&#039;<br \/>\n  AND amount &gt; 1000;  &#8212; \u6b64\u6761\u4ef6\u4f1a\u4e0b\u63a8\u5230\u6587\u4ef6\u8bfb\u53d6\u5c42<\/p>\n<h2>8. Join \u4f18\u5316<\/h2>\n<p>\u200bHive \u62e5\u6709\u591a\u79cd Join \u7b97\u6cd5&#xff0c;\u4ece\u57fa\u7840\u5230\u9ad8\u7ea7\u4f9d\u6b21\u4e3a&#xff1a;Common Join \u2192 Map Join \u2192 Bucket Map Join \u2192 Sort Merge Bucket Map Join\u3002\u4f18\u5316\u7a0b\u5ea6\u9010\u7ea7\u9012\u589e&#xff0c;\u9002\u7528\u6761\u4ef6\u4e5f\u9010\u7ea7\u4e25\u683c\u3002<\/p>\n<h3>8.1 Common Join<\/h3>\n<h4>8.1.1 \u539f\u7406<\/h4>\n<p>\u200bCommon Join \u662f Hive \u6700\u57fa\u7840&#xff0c;\u6700\u7a33\u5b9a\u7684 Join \u7b97\u6cd5&#xff0c;\u901a\u8fc7\u4e00\u4e2a\u5b8c\u6574\u7684 MapReduce \/ Spark Job \u5b8c\u6210<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260806181711-6a74cfa766adf.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h4>8.1.2 SQL\u793a\u4f8b<\/h4>\n<p><span class=\"token comment\">&#8212; \u8ba2\u5355\u8868 JOIN \u7528\u6237\u8868&#xff08;\u9ed8\u8ba4\u8d70Common Join&#xff09;<\/span><br \/>\n<span class=\"token keyword\">SELECT<\/span><br \/>\n    o<span class=\"token punctuation\">.<\/span>order_id<span class=\"token punctuation\">,<\/span><br \/>\n    o<span class=\"token punctuation\">.<\/span>amount<span class=\"token punctuation\">,<\/span><br \/>\n    u<span class=\"token punctuation\">.<\/span>user_name<span class=\"token punctuation\">,<\/span><br \/>\n    u<span class=\"token punctuation\">.<\/span>city<br \/>\n<span class=\"token keyword\">FROM<\/span> orders o<br \/>\n<span class=\"token keyword\">JOIN<\/span> users u <span class=\"token keyword\">ON<\/span> o<span class=\"token punctuation\">.<\/span>user_id <span class=\"token operator\">&#061;<\/span> u<span class=\"token punctuation\">.<\/span>user_id<br \/>\n<span class=\"token keyword\">WHERE<\/span> o<span class=\"token punctuation\">.<\/span>dt <span class=\"token operator\">&#061;<\/span> <span class=\"token string\">&#039;2026-07-25&#039;<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<h4>8.1.3 \u6267\u884c\u8ba1\u5212<\/h4>\n<p>Stage-1: Map Reduce<br \/>\n  Map Operator Tree:<br \/>\n    TableScan (orders) \u2192 Select \u2192 Reduce Output (key: user_id, tag:0)<br \/>\n    TableScan (users)  \u2192 Select \u2192 Reduce Output (key: user_id, tag:1)<br \/>\n  Reduce Operator Tree:<br \/>\n    Join Operator (Inner Join, key: user_id) \u2192 Select \u2192 File Output<\/p>\n<h4>8.1.4 \u4f18\u7f3a\u70b9<\/h4>\n<table>\n<tr>\u4f18\u70b9\u7f3a\u70b9<\/tr>\n<tbody>\n<tr>\n<td>\u6700\u7a33\u5b9a&#xff0c;\u9002\u7528\u6240\u6709\u573a\u666f<\/td>\n<td>\u9700\u8981\u5b8c\u6574\u7684 Shuffle \u8fc7\u7a0b<\/td>\n<\/tr>\n<tr>\n<td>\u65e0\u9700\u7279\u6b8a\u8868\u7ed3\u6784<\/td>\n<td>\u7f51\u7edc I\/O \u5f00\u9500\u5927<\/td>\n<\/tr>\n<tr>\n<td>\u65e0\u5185\u5b58\u9650\u5236<\/td>\n<td>\u5927\u8868 Join \u5927\u8868\u65f6\u6027\u80fd\u5dee<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>8.2 Map Join<\/h3>\n<h4>8.2.1 \u539f\u7406<\/h4>\n<p>\u200bMap Join \u5c06 \u5c0f\u8868\u5b8c\u5168\u52a0\u8f7d\u5230\u5206\u5e03\u5f0f\u5185\u5b58&#xff0c;\u5728 Map \u9636\u6bb5\u76f4\u63a5\u5b8c\u6210 Join&#xff0c;\u5b8c\u5168\u8df3\u8fc7 Shuffle \u548c Reduce \u9636\u6bb5\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260806181712-6a74cfa8312f6.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h4>8.2.2 \u793a\u4f8bSQL<\/h4>\n<p><span class=\"token comment\">&#8212; \u65b9\u5f0f\u4e00&#xff1a;\u4f7f\u7528 Hint \u663e\u5f0f\u6307\u5b9a Map Join(\u4e0d\u63a8\u8350)<\/span><br \/>\n<span class=\"token keyword\">SELECT<\/span> <span class=\"token comment\">\/*&#043; MAPJOIN(u) *\/<\/span><br \/>\n    o<span class=\"token punctuation\">.<\/span>order_id<span class=\"token punctuation\">,<\/span><br \/>\n    o<span class=\"token punctuation\">.<\/span>amount<span class=\"token punctuation\">,<\/span><br \/>\n    u<span class=\"token punctuation\">.<\/span>user_name<span class=\"token punctuation\">,<\/span><br \/>\n    u<span class=\"token punctuation\">.<\/span>city<br \/>\n<span class=\"token keyword\">FROM<\/span> orders o<br \/>\n<span class=\"token keyword\">JOIN<\/span> users u <span class=\"token keyword\">ON<\/span> o<span class=\"token punctuation\">.<\/span>user_id <span class=\"token operator\">&#061;<\/span> u<span class=\"token punctuation\">.<\/span>user_id<span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">&#8212; \u65b9\u5f0f\u4e8c&#xff1a;\u5f00\u542f\u81ea\u52a8\u8f6c\u6362&#xff08;\u63a8\u8350&#xff09;<\/span><br \/>\n<span class=\"token keyword\">SET<\/span> hive<span class=\"token punctuation\">.<\/span>auto<span class=\"token punctuation\">.<\/span><span class=\"token keyword\">convert<\/span><span class=\"token punctuation\">.<\/span><span class=\"token keyword\">join<\/span> <span class=\"token operator\">&#061;<\/span> <span class=\"token boolean\">true<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token keyword\">SET<\/span> hive<span class=\"token punctuation\">.<\/span>mapjoin<span class=\"token punctuation\">.<\/span>smalltable<span class=\"token punctuation\">.<\/span>filesize <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">25000000<\/span><span class=\"token punctuation\">;<\/span>  <span class=\"token comment\">&#8212; \u5c0f\u8868\u9608\u503c25MB<\/span><\/p>\n<p><span class=\"token keyword\">SELECT<\/span><br \/>\n    o<span class=\"token punctuation\">.<\/span>order_id<span class=\"token punctuation\">,<\/span><br \/>\n    o<span class=\"token punctuation\">.<\/span>amount<span class=\"token punctuation\">,<\/span><br \/>\n    u<span class=\"token punctuation\">.<\/span>user_name<span class=\"token punctuation\">,<\/span><br \/>\n    u<span class=\"token punctuation\">.<\/span>city<br \/>\n<span class=\"token keyword\">FROM<\/span> orders o<br \/>\n<span class=\"token keyword\">JOIN<\/span> users u <span class=\"token keyword\">ON<\/span> o<span class=\"token punctuation\">.<\/span>user_id <span class=\"token operator\">&#061;<\/span> u<span class=\"token punctuation\">.<\/span>user_id<span class=\"token punctuation\">;<\/span><\/p>\n<h4>8.2.3 \u53c2\u6570\u8bbe\u7f6e<\/h4>\n<p># \u662f\u5426\u81ea\u52a8\u5c06 Common Join \u8f6c\u4e3a Map Join&#xff0c;\u9ed8\u8ba4 true<br \/>\nhive.auto.convert.join &#061; true<br \/>\n# \u5c0f\u8868\u5927\u5c0f\u9608\u503c&#xff0c;\u5c0f\u4e8e\u6b64\u503c\u81ea\u52a8 Map Join&#xff0c;\u9ed8\u8ba4 25000000(25MB)<br \/>\nhive.mapjoin.smalltable.filesize &#061; 25000000<br \/>\n# \u662f\u5426\u65e0\u6761\u4ef6\u8f6c\u5316&#xff08;\u4e0d\u9700\u8981\u8fd0\u884c\u65f6\u5224\u65ad&#xff09;&#xff0c;\u9ed8\u8ba4 true<br \/>\nhive.auto.convert.join.noconditionaltask &#061; true<br \/>\n# \u65e0\u6761\u4ef6\u8f6c\u5316\u5927\u5c0f\u9608\u503c&#xff0c;\u9ed8\u8ba4 10000000(10MB)<br \/>\nhive.auto.convert.join.noconditionaltask.size &#061; 10000000<br \/>\n# Map Join \u540e\u8ddf Group By \u65f6\u54c8\u5e0c\u8868\u7684\u5185\u5b58\u5360\u6bd4&#xff0c;\u9ed8\u8ba4 0.3<br \/>\nhive.mapjoin.followby.map.aggr.hash.percentmemory &#061; 0.3<\/p>\n<h4>8.2.4 \u9002\u7528\u6761\u4ef6<\/h4>\n<ul>\n<li>\u2705 \u5927\u8868 Join \u5c0f\u8868&#xff08;\u5c0f\u8868 &lt; 25MB&#xff0c;\u53ef\u8c03&#xff09;<\/li>\n<li>\u2705 \u5c0f\u8868\u80fd\u5b8c\u5168\u88c5\u5165\u5355\u4e2aExecutor\u5185\u5b58&#xff0c;\u65e2\u6574\u4e2a Hash Map\u7684\u5927\u5c0f\u4e0d\u80fd\u8d85\u51fa 14GB<\/li>\n<li>\u274c \u4e0d\u9002\u7528\u4e8e\u5927\u8868 join \u5927\u8868<\/li>\n<li>\u274c \u4e0d\u9002\u7528\u4e8e\u975e\u7b49\u503c Join&#xff08;\u5982 on a.id &gt; b.id &#xff09;<\/li>\n<\/ul>\n<h4>8.2.5 \u6027\u80fd\u5bf9\u6bd4<\/h4>\n<p>Common Join &#xff1b; 100GB\u5927\u8868 JOIN 20MB\u5c0f\u8868 -&gt; Shuffle 100GB -&gt; \u8017\u65f6 30min<br \/>\nMap Join &#xff1a;  100GB\u5927\u8868 JOIN 20MB\u5c0f\u8868 -&gt; \u65e0 Shuffle   -&gt; \u8017\u65f6 5min<br \/>\n\u5982\u679c\u5927\u8868\u7684\u6570\u636e\u91cf\u8d8a\u5927&#xff0c;\u8fd9\u4e2a\u5dee\u8ddd\u4f1a\u8d8a\u6765\u8d8a\u5927&#xff0c;\u7279\u522b\u65f6\u9488\u5bf9\u4e8e\u5173\u8054 \u7701\u4efd\u8868(\u6570\u636e\u91cf\u5c0f) \u65f6&#xff0c;\u4f7f\u7528 Map Join \u80fd\u591f\u6781\u5927\u7684\u63d0\u5347\u6548\u7387<\/p>\n<h3>8.3 Bucket Map Join<\/h3>\n<h4>8.3.1 \u539f\u7406<\/h4>\n<p>\u200bBucket Map Join \u662f Map Join \u7684\u6269\u5c55&#xff0c;\u6253\u7834\u4e86&#034;\u5c0f\u8868\u5fc5\u987b\u5b8c\u5168\u88c5\u5165\u5185\u5b58&#034;\u7684\u9650\u5236&#xff0c;\u53ef\u7528\u4e8e \u5927\u8868 JOIN \u5927\u8868\u7684\u573a\u666f\u3002<\/p>\n<p>\u200b\u6838\u5fc3\u601d\u60f3&#xff1a;\u5982\u679c\u4e24\u5f20\u5927\u8868\u90fd\u6309\u7167 Join Key \u8fdb\u884c\u4e86\u5206\u6876&#xff08;Bucket&#xff09;&#xff0c;\u90a3\u4e48 \u6876N \u7684\u6570\u636e\u53ea\u4f1a\u4e0e\u53e6\u4e00\u5f20\u8868\u7684 \u6876M \u8fdb\u884c Join &#xff08;N\u4e8eM\u5fc5\u987b\u662f\u6574\u6570\u500d\u5173\u7cfb&#xff09;\u3002\u56e0\u6b64 Map \u7aef\u65e0\u9700\u7f13\u5b58\u5c0f\u8868\u5168\u91cf\u6570\u636e&#xff0c;\u53ea\u9700\u7f13\u5b58\u5bf9\u5e94\u6876\u53f7\u7684\u6570\u636e\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260806181712-6a74cfa860fe0.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h4>8.3.2 \u793a\u4f8bSQL<\/h4>\n<p>Step 1 : \u521b\u5efa\u5206\u6876\u8868<\/p>\n<p><span class=\"token comment\">&#8212; \u8ba2\u5355\u8868&#xff1a;\u6309user_id\u52068\u4e2a\u6876<\/span><br \/>\n<span class=\"token keyword\">CREATE<\/span> <span class=\"token keyword\">TABLE<\/span> orders_bucketed <span class=\"token punctuation\">(<\/span><br \/>\n    order_id    <span class=\"token keyword\">BIGINT<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    user_id     <span class=\"token keyword\">BIGINT<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    amount      <span class=\"token keyword\">DECIMAL<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">10<\/span><span class=\"token punctuation\">,<\/span><span class=\"token number\">2<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    order_time  <span class=\"token keyword\">TIMESTAMP<\/span><br \/>\n<span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token keyword\">CLUSTERED<\/span> <span class=\"token keyword\">BY<\/span> <span class=\"token punctuation\">(<\/span>user_id<span class=\"token punctuation\">)<\/span> <span class=\"token keyword\">INTO<\/span> <span class=\"token number\">8<\/span> BUCKETS<br \/>\nSTORED <span class=\"token keyword\">AS<\/span> ORC<span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">&#8212; \u7528\u6237\u8868&#xff1a;\u6309user_id\u52068\u4e2a\u6876&#xff08;\u62164\u4e2a\u6876&#xff0c;\u5fc5\u987b\u662f\u500d\u6570\u5173\u7cfb&#xff09;<\/span><br \/>\n<span class=\"token keyword\">CREATE<\/span> <span class=\"token keyword\">TABLE<\/span> users_bucketed <span class=\"token punctuation\">(<\/span><br \/>\n    user_id     <span class=\"token keyword\">BIGINT<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    user_name   STRING<span class=\"token punctuation\">,<\/span><br \/>\n    city        STRING<span class=\"token punctuation\">,<\/span><br \/>\n    register_time <span class=\"token keyword\">TIMESTAMP<\/span><br \/>\n<span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token keyword\">CLUSTERED<\/span> <span class=\"token keyword\">BY<\/span> <span class=\"token punctuation\">(<\/span>user_id<span class=\"token punctuation\">)<\/span> <span class=\"token keyword\">INTO<\/span> <span class=\"token number\">8<\/span> BUCKETS<br \/>\nSTORED <span class=\"token keyword\">AS<\/span> ORC<span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">&#8212; \u63d2\u5165\u6570\u636e&#xff08;\u5fc5\u987b\u4f7f\u7528INSERT\u624d\u80fd\u6b63\u786e\u5206\u6876&#xff09;<\/span><br \/>\n<span class=\"token keyword\">INSERT<\/span> OVERWRITE <span class=\"token keyword\">TABLE<\/span> orders_bucketed<br \/>\n<span class=\"token keyword\">SELECT<\/span> order_id<span class=\"token punctuation\">,<\/span> user_id<span class=\"token punctuation\">,<\/span> amount<span class=\"token punctuation\">,<\/span> order_time <span class=\"token keyword\">FROM<\/span> orders<span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token keyword\">INSERT<\/span> OVERWRITE <span class=\"token keyword\">TABLE<\/span> users_bucketed<br \/>\n<span class=\"token keyword\">SELECT<\/span> user_id<span class=\"token punctuation\">,<\/span> user_name<span class=\"token punctuation\">,<\/span> city<span class=\"token punctuation\">,<\/span> register_time <span class=\"token keyword\">FROM<\/span> users<span class=\"token punctuation\">;<\/span><\/p>\n<p>Step 2 &#xff1a; \u6267\u884c Bucket Map Join<\/p>\n<p><span class=\"token comment\">&#8212; \u8bbe\u7f6e\u53c2\u6570<\/span><br \/>\n<span class=\"token keyword\">SET<\/span> hive<span class=\"token punctuation\">.<\/span><span class=\"token keyword\">optimize<\/span><span class=\"token punctuation\">.<\/span>bucketmapjoin <span class=\"token operator\">&#061;<\/span> <span class=\"token boolean\">true<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token keyword\">SET<\/span> hive<span class=\"token punctuation\">.<\/span>auto<span class=\"token punctuation\">.<\/span><span class=\"token keyword\">convert<\/span><span class=\"token punctuation\">.<\/span><span class=\"token keyword\">join<\/span> <span class=\"token operator\">&#061;<\/span> <span class=\"token boolean\">true<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">&#8212; \u4f7f\u7528Hint\u6307\u5b9a<\/span><br \/>\n<span class=\"token keyword\">SELECT<\/span> <span class=\"token comment\">\/*&#043; MAPJOIN(u) *\/<\/span><br \/>\n    o<span class=\"token punctuation\">.<\/span>order_id<span class=\"token punctuation\">,<\/span><br \/>\n    o<span class=\"token punctuation\">.<\/span>amount<span class=\"token punctuation\">,<\/span><br \/>\n    u<span class=\"token punctuation\">.<\/span>user_name<span class=\"token punctuation\">,<\/span><br \/>\n    u<span class=\"token punctuation\">.<\/span>city<br \/>\n<span class=\"token keyword\">FROM<\/span> orders_bucketed o<br \/>\n<span class=\"token keyword\">JOIN<\/span> users_bucketed u <span class=\"token keyword\">ON<\/span> o<span class=\"token punctuation\">.<\/span>user_id <span class=\"token operator\">&#061;<\/span> u<span class=\"token punctuation\">.<\/span>user_id<span class=\"token punctuation\">;<\/span><\/p>\n<h4>8.3.3 \u53c2\u6570\u8bbe\u7f6e<\/h4>\n<p># \u662f\u5426\u542f\u7528 Bucket Map Join&#xff0c;\u9ed8\u8ba4 false<br \/>\nhive.optimize.bucketmapjoin &#061; false<br \/>\n# \u9700\u8981\u540c\u65f6\u5f00\u542f Map Join \u81ea\u52a8\u8f6c\u5316&#xff0c;\u9ed8\u8ba4 true<br \/>\nhive.auto.convert.join &#061; true<\/p>\n<h4>8.3.4 \u9002\u7528\u6761\u4ef6&#xff08;\u5fc5\u987b\u6ee1\u8db3&#xff09;<\/h4>\n<li>\u2705 \u4e24\u5f20\u8868\u90fd\u662f \u5206\u6876\u8868&#xff08;CLUSTERED BY&#xff09;<\/li>\n<li>\u2705 \u5206\u6876\u5b57\u6bb5\u5fc5\u987b\u662f Join Key<\/li>\n<li>\u2705 \u4e24\u8868\u6876\u6570\u91cf \u76f8\u540c\u6216\u6210\u6574\u6570\u500d\u5173\u7cfb&#xff08;\u5982 8 \u548c 8&#xff0c;\u6216 4 \u548c 8&#xff09;<\/li>\n<li>\u26a0\ufe0f \u4e0d\u652f\u6301\u81ea\u52a8\u8f6c\u6362&#xff0c;\u901a\u5e38\u9700\u8981 Hint \u6216\u53c2\u6570\u914d\u5408<\/li>\n<h3>8.4 Sort Merge Bucketed Map Join (SMB Join)<\/h3>\n<h4>8.4.1 \u539f\u7406<\/h4>\n<p>\u200bSMB Join \u662f Bucket Map Join \u7684\u8fdb\u4e00\u6b65\u4f18\u5316\u3002\u5728 Bucket Map Join \u4e2d&#xff0c;\u6bcf\u4e2a\u6876\u7684\u6570\u636e\u52a0\u8f7d\u5230\u5185\u5b58\u4e4b\u540e\u4ecd\u9700\u8fdb\u884c Hash \u5339\u914d\u3002\u800c SMB Join \u8981\u6c42 \u6876\u5185\u6570\u636e\u6309 Join Key \u6392\u5e8f&#xff0c;\u8fd9\u6837\u4e24\u4e2a\u6876\u7684\u6570\u636e\u5c31\u53ef\u4ee5\u8fdb\u884c \u5f52\u5e76\u6392\u5e8f\u5f0f\u5339\u914d&#xff08;Merge Join&#xff09;&#xff0c;\u65e0\u9700\u5c06\u4efb\u4f55\u4e00\u4e2a\u6876\u5b8c\u5168\u52a0\u8f7d\u5230\u5185\u5b58\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260806181712-6a74cfa8ca2f2.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h4>8.4.2 \u793a\u4f8bSQL<\/h4>\n<p>Step 1 &#xff1a; \u521b\u5efa\u6392\u5e8f\u5206\u6876\u8868<\/p>\n<p><span class=\"token comment\">&#8212; \u6ce8\u610f&#xff1a;CLUSTERED BY &#043; SORTED BY<\/span><br \/>\n<span class=\"token keyword\">CREATE<\/span> <span class=\"token keyword\">TABLE<\/span> orders_smb <span class=\"token punctuation\">(<\/span><br \/>\n    order_id    <span class=\"token keyword\">BIGINT<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    user_id     <span class=\"token keyword\">BIGINT<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    amount      <span class=\"token keyword\">DECIMAL<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">10<\/span><span class=\"token punctuation\">,<\/span><span class=\"token number\">2<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    order_time  <span class=\"token keyword\">TIMESTAMP<\/span><br \/>\n<span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token keyword\">CLUSTERED<\/span> <span class=\"token keyword\">BY<\/span> <span class=\"token punctuation\">(<\/span>user_id<span class=\"token punctuation\">)<\/span> SORTED <span class=\"token keyword\">BY<\/span> <span class=\"token punctuation\">(<\/span>user_id<span class=\"token punctuation\">)<\/span> <span class=\"token keyword\">INTO<\/span> <span class=\"token number\">8<\/span> BUCKETS<br \/>\nSTORED <span class=\"token keyword\">AS<\/span> ORC<span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token keyword\">CREATE<\/span> <span class=\"token keyword\">TABLE<\/span> users_smb <span class=\"token punctuation\">(<\/span><br \/>\n    user_id     <span class=\"token keyword\">BIGINT<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    user_name   STRING<span class=\"token punctuation\">,<\/span><br \/>\n    city        STRING<span class=\"token punctuation\">,<\/span><br \/>\n    register_time <span class=\"token keyword\">TIMESTAMP<\/span><br \/>\n<span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token keyword\">CLUSTERED<\/span> <span class=\"token keyword\">BY<\/span> <span class=\"token punctuation\">(<\/span>user_id<span class=\"token punctuation\">)<\/span> SORTED <span class=\"token keyword\">BY<\/span> <span class=\"token punctuation\">(<\/span>user_id<span class=\"token punctuation\">)<\/span> <span class=\"token keyword\">INTO<\/span> <span class=\"token number\">8<\/span> BUCKETS<br \/>\nSTORED <span class=\"token keyword\">AS<\/span> ORC<span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">&#8212; \u63d2\u5165\u6570\u636e<\/span><br \/>\n<span class=\"token keyword\">INSERT<\/span> OVERWRITE <span class=\"token keyword\">TABLE<\/span> orders_smb<br \/>\n<span class=\"token keyword\">SELECT<\/span> order_id<span class=\"token punctuation\">,<\/span> user_id<span class=\"token punctuation\">,<\/span> amount<span class=\"token punctuation\">,<\/span> order_time <span class=\"token keyword\">FROM<\/span> orders<span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token keyword\">INSERT<\/span> OVERWRITE <span class=\"token keyword\">TABLE<\/span> users_smb<br \/>\n<span class=\"token keyword\">SELECT<\/span> user_id<span class=\"token punctuation\">,<\/span> user_name<span class=\"token punctuation\">,<\/span> city<span class=\"token punctuation\">,<\/span> register_time <span class=\"token keyword\">FROM<\/span> users<span class=\"token punctuation\">;<\/span><\/p>\n<p>Step 2 &#xff1a; \u6267\u884c SMB Join<\/p>\n<p><span class=\"token comment\">&#8212; \u8bbe\u7f6e\u53c2\u6570<\/span><br \/>\n<span class=\"token keyword\">SET<\/span> hive<span class=\"token punctuation\">.<\/span><span class=\"token keyword\">optimize<\/span><span class=\"token punctuation\">.<\/span>bucketmapjoin <span class=\"token operator\">&#061;<\/span> <span class=\"token boolean\">true<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token keyword\">SET<\/span> hive<span class=\"token punctuation\">.<\/span><span class=\"token keyword\">optimize<\/span><span class=\"token punctuation\">.<\/span>bucketmapjoin<span class=\"token punctuation\">.<\/span>sortedmerge <span class=\"token operator\">&#061;<\/span> <span class=\"token boolean\">true<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token keyword\">SET<\/span> hive<span class=\"token punctuation\">.<\/span>auto<span class=\"token punctuation\">.<\/span><span class=\"token keyword\">convert<\/span><span class=\"token punctuation\">.<\/span><span class=\"token keyword\">join<\/span> <span class=\"token operator\">&#061;<\/span> <span class=\"token boolean\">true<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token keyword\">SELECT<\/span> <span class=\"token comment\">\/*&#043; MAPJOIN(u) *\/<\/span><br \/>\n    o<span class=\"token punctuation\">.<\/span>order_id<span class=\"token punctuation\">,<\/span><br \/>\n    o<span class=\"token punctuation\">.<\/span>amount<span class=\"token punctuation\">,<\/span><br \/>\n    u<span class=\"token punctuation\">.<\/span>user_name<span class=\"token punctuation\">,<\/span><br \/>\n    u<span class=\"token punctuation\">.<\/span>city<br \/>\n<span class=\"token keyword\">FROM<\/span> orders_smb o<br \/>\n<span class=\"token keyword\">JOIN<\/span> users_smb u <span class=\"token keyword\">ON<\/span> o<span class=\"token punctuation\">.<\/span>user_id <span class=\"token operator\">&#061;<\/span> u<span class=\"token punctuation\">.<\/span>user_id<span class=\"token punctuation\">;<\/span><\/p>\n<h4>8.4.3 \u53c2\u6570\u8bbe\u7f6e<\/h4>\n<p># \u662f\u5426\u542f\u7528 SMB Join&#xff0c;\u9ed8\u8ba4\u503c false<br \/>\nhive.optimize.bucketmapjoin.sortedmerge &#061; false<br \/>\n# \u5fc5\u987b\u540c\u65f6\u542f\u7528 Bucket Map Join \u548c Map Join \u81ea\u52a8\u8f6c\u5316<br \/>\nhive.optimize.bucketmapjoin &#061; true<br \/>\nhive.auto.convert.join &#061; true<\/p>\n<h4>8.4.4 \u9002\u7528\u6761\u4ef6&#xff08;\u6700\u4e25\u683c&#xff09;<\/h4>\n<li>\u2705 \u4e24\u8868\u90fd\u662f\u5206\u6876\u8868<\/li>\n<li>\u2705 \u5206\u6876\u5b57\u6bb5 &#061; Join Key<\/li>\n<li>\u2705 \u6876\u5185\u6570\u636e\u6309 Join Key \u6392\u5e8f&#xff08;SORTED BY&#xff09;<\/li>\n<li>\u2705 \u4e24\u8868\u6876\u6570\u91cf\u76f8\u540c\u6216\u6210\u500d\u6570<\/li>\n<li>\u2705 \u4ec5\u652f\u6301 \u7b49\u503c Join<\/li>\n<h3>8.5 \u56db\u79cd Join \u7b97\u6cd5\u5bf9\u6bd4\u603b\u7ed3<\/h3>\n<table>\n<tr>\u7279\u6027Common JoinMap JoinBucket Map JoinSMB Join<\/tr>\n<tbody>\n<tr>\n<td>\u662f\u5426\u9700\u8981Shuffle<\/td>\n<td>\u2705 \u662f<\/td>\n<td>\u274c \u5426<\/td>\n<td>\u274c \u5426<\/td>\n<td>\u274c \u5426<\/td>\n<\/tr>\n<tr>\n<td>\u662f\u5426\u9700\u8981Reduce<\/td>\n<td>\u2705 \u662f<\/td>\n<td>\u274c \u5426<\/td>\n<td>\u274c \u5426<\/td>\n<td>\u274c \u5426<\/td>\n<\/tr>\n<tr>\n<td>\u9002\u7528\u573a\u666f<\/td>\n<td>\u4efb\u610f<\/td>\n<td>\u5927\u8868&#043;\u5c0f\u8868<\/td>\n<td>\u5927\u8868&#043;\u5927\u8868(\u5206\u6876)<\/td>\n<td>\u5927\u8868&#043;\u5927\u8868(\u6392\u5e8f\u5206\u6876)<\/td>\n<\/tr>\n<tr>\n<td>\u5185\u5b58\u9700\u6c42<\/td>\n<td>\u4f4e<\/td>\n<td>\u9ad8(\u88c5\u5c0f\u8868)<\/td>\n<td>\u4e2d(\u88c5\u4e00\u4e2a\u6876)<\/td>\n<td>\u6781\u4f4e(\u53cc\u6307\u9488)<\/td>\n<\/tr>\n<tr>\n<td>\u8868\u7ed3\u6784\u8981\u6c42<\/td>\n<td>\u65e0<\/td>\n<td>\u65e0<\/td>\n<td>\u5206\u6876\u8868<\/td>\n<td>\u6392\u5e8f\u5206\u6876\u8868<\/td>\n<\/tr>\n<tr>\n<td>\u6027\u80fd<\/td>\n<td>\u2605\u2605<\/td>\n<td>\u2605\u2605\u2605\u2605<\/td>\n<td>\u2605\u2605\u2605\u2605\u2606<\/td>\n<td>\u2605\u2605\u2605\u2605\u2605<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>9. \u5c0f\u6587\u4ef6\u5408\u5e76<\/h2>\n<table>\n<tr>\u5f71\u54cd\u5c42\u9762\u5177\u4f53\u95ee\u9898<\/tr>\n<tbody>\n<tr>\n<td>HDFS NameNode<\/td>\n<td>\u6bcf\u4e2a\u6587\u4ef6\/\u76ee\u5f55\/\u5757\u5360\u7528\u7ea6150\u5b57\u8282\u5143\u6570\u636e&#xff0c;\u767e\u4e07\u5c0f\u6587\u4ef6 \u2192 150MB&#043; \u5185\u5b58<\/td>\n<\/tr>\n<tr>\n<td>\u8ba1\u7b97\u5f15\u64ce<\/td>\n<td>\u6bcf\u4e2a\u5c0f\u6587\u4ef6\u5bf9\u5e94\u4e00\u4e2aMap Task&#xff0c;Task\u542f\u52a8\u5f00\u9500 &gt;&gt; \u5b9e\u9645\u8ba1\u7b97<\/td>\n<\/tr>\n<tr>\n<td>\u4e0b\u6e38\u4efb\u52a1<\/td>\n<td>getSplits \u64cd\u4f5c\u8017\u65f6\u4e0e\u6587\u4ef6\u6570\u6210\u6b63\u6bd4<\/td>\n<\/tr>\n<tr>\n<td>\u5b58\u50a8\u6548\u7387<\/td>\n<td>\u5c0f\u6587\u4ef6\u65e0\u6cd5\u5145\u5206\u5229\u7528HDFS\u5757&#xff08;128MB&#xff09;&#xff0c;\u6d6a\u8d39\u7a7a\u95f4<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>9.1 \u5c0f\u6587\u4ef6\u4ea7\u751f\u539f\u56e0<\/h3>\n<p>1. \u52a8\u6001\u5206\u533a\u5199\u5165&#xff1a;\u6bcf\u4e2a\u5206\u533a\u4ea7\u751f\u72ec\u7acb\u6587\u4ef6<br \/>\n   INSERT INTO TABLE t PARTITION(dt) SELECT &#8230;, dt FROM source;<br \/>\n   \u2192 100\u4e2a\u5206\u533a \u00d7 200\u4e2aReducer &#061; 20000\u4e2a\u6587\u4ef6&#xff01;<\/p>\n<p>2. Reduce\u6570\u91cf\u8fc7\u591a&#xff1a;\u6bcf\u4e2aReduce\u8f93\u51fa\u4e00\u4e2a\u6587\u4ef6<br \/>\n   200\u4e2aReducer \u2192 200\u4e2a\u6587\u4ef6&#xff08;\u53ef\u80fd\u6bcf\u4e2a\u624d\u51e0MB&#xff09;<\/p>\n<p>3. \u9891\u7e41INSERT INTO&#xff1a;\u6bcf\u6b21\u8ffd\u52a0\u90fd\u4ea7\u751f\u65b0\u6587\u4ef6<\/p>\n<p>4. Spark\u5e76\u884c\u5ea6\u8fc7\u9ad8&#xff1a;spark.sql.shuffle.partitions&#061;200 \u2192 200\u4e2a\u8f93\u51fa\u6587\u4ef6<\/p>\n<h3>9.2 \u4f18\u5316\u65b9\u6848\u4e00&#xff1a;Hive \u53c2\u6570\u63a7\u5236\u5408\u5e76<\/h3>\n<p>&#8212; &#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061; \u6838\u5fc3\u53c2\u6570 &#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;<\/p>\n<p>&#8212; 1. \u5f00\u542fMap\u8f93\u51fa\u5408\u5e76&#xff08;Map-Only\u4efb\u52a1&#xff09;<br \/>\nSET hive.merge.mapfiles &#061; true;<\/p>\n<p>&#8212; 2. \u5f00\u542fReduce\u8f93\u51fa\u5408\u5e76&#xff08;MapReduce\u4efb\u52a1&#xff09;<br \/>\nSET hive.merge.mapredfiles &#061; true;<\/p>\n<p>&#8212; 3. \u3010Hive on Spark \u4e13\u7528\u3011\u5f00\u542fSpark\u8f93\u51fa\u5408\u5e76<br \/>\nSET hive.merge.sparkfiles &#061; true;<\/p>\n<p>&#8212; 4. \u5408\u5e76\u540e\u76ee\u6807\u6587\u4ef6\u5927\u5c0f&#xff08;\u9ed8\u8ba4256MB&#xff09;<br \/>\nSET hive.merge.size.per.task &#061; 268435456;<\/p>\n<p>&#8212; 5. \u89e6\u53d1\u5408\u5e76\u7684\u5e73\u5747\u6587\u4ef6\u5927\u5c0f\u9608\u503c&#xff08;\u5c0f\u4e8e\u6b64\u503c\u624d\u5408\u5e76&#xff0c;\u9ed8\u8ba416MB&#xff09;<br \/>\nSET hive.merge.smallfiles.avgsize &#061; 16000000;<\/p>\n<p>&#8212; &#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061; SQL \u793a\u4f8b &#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;<br \/>\nINSERT OVERWRITE TABLE dws_order_daily PARTITION(dt &#061; &#039;2026-07-25&#039;)<br \/>\nSELECT<br \/>\n    city,<br \/>\n    category,<br \/>\n    COUNT(*) AS order_cnt,<br \/>\n    SUM(amount) AS total_amount<br \/>\nFROM orders<br \/>\nWHERE dt &#061; &#039;2026-07-25&#039;<br \/>\nGROUP BY city, category;<br \/>\n&#8212; \u6267\u884c\u540e&#xff0c;\u5982\u679c\u8f93\u51fa\u6587\u4ef6\u5e73\u5747\u5927\u5c0f &lt; 16MB&#xff0c;\u4f1a\u81ea\u52a8\u542f\u52a8\u5408\u5e76Job<\/p>\n<h3>9.3  \u4f18\u5316\u65b9\u6848\u4e8c&#xff1a;\u63a7\u5236\u8f93\u51fa\u6587\u4ef6\u6570\u91cf&#xff08;\u6e90\u5934\u6cbb\u7406&#xff09;<\/h3>\n<p>&#8212; \u65b9\u6cd51&#xff1a;\u51cf\u5c11Reduce\u6570\u91cf<br \/>\nSET spark.sql.shuffle.partitions &#061; 50;  &#8212; \u4ece200\u51cf\u523050<\/p>\n<p>&#8212; \u65b9\u6cd52&#xff1a;\u4f7f\u7528 DISTRIBUTE BY \u63a7\u5236\u8f93\u51fa<br \/>\nINSERT OVERWRITE TABLE dws_order_daily PARTITION(dt &#061; &#039;2026-07-25&#039;)<br \/>\nSELECT<br \/>\n    city,<br \/>\n    category,<br \/>\n    COUNT(*) AS order_cnt,<br \/>\n    SUM(amount) AS total_amount<br \/>\nFROM orders<br \/>\nWHERE dt &#061; &#039;2026-07-25&#039;<br \/>\nGROUP BY city, category<br \/>\nDISTRIBUTE BY city;  &#8212; \u6309city\u5206\u53d1&#xff0c;\u76f8\u540ccity\u7684\u6570\u636e\u5199\u5165\u540c\u4e00\u6587\u4ef6<\/p>\n<p>&#8212; \u65b9\u6cd53&#xff1a;\u4f7f\u7528 COALESCE Hint&#xff08;Spark 3.0&#043;&#xff09;<br \/>\nINSERT OVERWRITE TABLE result_table<br \/>\nSELECT \/*&#043; COALESCE(10) *\/<br \/>\n    city, SUM(amount) AS total<br \/>\nFROM orders<br \/>\nGROUP BY city;<br \/>\n&#8212; \u5f3a\u5236\u5c06\u8f93\u51fa\u5408\u5e76\u4e3a10\u4e2a\u6587\u4ef6<\/p>\n<p>&#8212; \u65b9\u6cd54&#xff1a;\u4f7f\u7528 REPARTITION Hint<br \/>\nINSERT OVERWRITE TABLE result_table<br \/>\nSELECT \/*&#043; REPARTITION(10) *\/<br \/>\n    city, SUM(amount) AS total<br \/>\nFROM orders<br \/>\nGROUP BY city;<\/p>\n<h3>9.4 \u4f18\u5316\u65b9\u6848\u4e09&#xff1a;\u8f93\u5165\u7aef\u5408\u5e76&#xff08;CombineHiveInputFormat&#xff09;<\/h3>\n<p>&#8212; \u6bcf\u4e2a\u8bfb\u8868 partition \u7684\u6700\u5927\u5b57\u8282\u6570&#xff08;\u9ed8\u8ba4 128MB&#xff0c;\u8c03\u5927&#061;task \u53d8\u5c11&#xff0c;\u8c03\u5c0f&#061;task \u53d8\u591a&#xff09;<br \/>\nSET spark.sql.files.maxPartitionBytes &#061; 268435456;   &#8212; 256MB<br \/>\n&#8212; \u6253\u5f00\u4e00\u4e2a\u6587\u4ef6\u7684&#034;\u4ee3\u4ef7&#034;\u6298\u7b97\u5b57\u8282&#xff0c;\u5f71\u54cd\u5c0f\u6587\u4ef6\u662f\u5426\u88ab\u5408\u5e76\u8fdb\u540c\u4e00\u4e2a partition<br \/>\nSET spark.sql.files.openCostInBytes &#061; 4194304;       &#8212; 4MB<br \/>\n&#8212; \u8bfb\u8868 partition \u6570\u4e0b\u9650<br \/>\nSET spark.sql.files.minPartitionNum &#061; 1;<\/p>\n<p>&#8212; SQL\u793a\u4f8b&#xff1a;\u8bfb\u53d6\u6709\u5927\u91cf\u5c0f\u6587\u4ef6\u7684\u8868<br \/>\nSELECT city, SUM(amount)<br \/>\nFROM orders_with_small_files  &#8212; \u8be5\u8868\u670910000\u4e2a\u5c0f\u6587\u4ef6<br \/>\nWHERE dt &#061; &#039;2026-07-25&#039;<br \/>\nGROUP BY city;<br \/>\n&#8212; \u4f18\u5316\u524d&#xff1a;10000\u4e2aMap Task<br \/>\n&#8212; \u4f18\u5316\u540e&#xff1a;\u7ea6 10000\u00d7\u5c0f\u6587\u4ef6\u5927\u5c0f \/ 256MB \u2248 \u51e0\u5341\u4e2aMap Task<\/p>\n<h3>9.5  \u4f18\u5316\u65b9\u6848\u56db&#xff1a;ORC\/Parquet \u6587\u4ef6\u4e13\u7528\u5408\u5e76<\/h3>\n<p>&#8212; ORC \u6587\u4ef6\u65e0\u635f\u5408\u5e76&#xff08;\u4e0d\u91cd\u65b0\u8ba1\u7b97&#xff0c;\u4ec5\u5408\u5e76\u6587\u4ef6&#xff09;<br \/>\nALTER TABLE orders PARTITION(dt&#061;&#039;2026-07-25&#039;) CONCATENATE;<\/p>\n<p>&#8212; \u6216\u8005\u901a\u8fc7\u91cd\u5199\u5b9e\u73b0\u5408\u5e76<br \/>\nINSERT OVERWRITE TABLE orders PARTITION(dt&#061;&#039;2026-07-25&#039;)<br \/>\nSELECT * FROM orders WHERE dt&#061;&#039;2026-07-25&#039;;<\/p>\n<h3>9.6 \u5c0f\u6587\u4ef6\u6cbb\u7406\u6700\u4f73\u5b9e\u8df5<\/h3>\n<p>&#8212; &#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061; \u5b8c\u6574\u7684ETL\u4efb\u52a1\u6a21\u677f &#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;<\/p>\n<p>&#8212; \u8f93\u5165\u7aef\u5408\u5e76<br \/>\nSET hive.input.format &#061; org.apache.hadoop.hive.ql.io.CombineHiveInputFormat;<\/p>\n<p>&#8212; \u8f93\u51fa\u7aef\u5408\u5e76<br \/>\nSET hive.merge.sparkfiles &#061; true;<br \/>\nSET hive.merge.size.per.task &#061; 268435456;<br \/>\nSET hive.merge.smallfiles.avgsize &#061; 64000000;<\/p>\n<p>&#8212; \u63a7\u5236\u5e76\u884c\u5ea6<br \/>\nSET spark.sql.shuffle.partitions &#061; 100;<\/p>\n<p>&#8212; AQE(\u540e\u7eed\u7ae0\u8282\u8bb2\u89e3)<br \/>\nSET spark.sql.adaptive.enabled &#061; true;<br \/>\nSET spark.sql.adaptive.coalescePartitions.enabled &#061; true;<\/p>\n<p>&#8212; \u4e1a\u52a1SQL<br \/>\nINSERT OVERWRITE TABLE dws_user_order PARTITION(dt &#061; &#039;2026-07-25&#039;)<br \/>\nSELECT<br \/>\n    u.user_id,<br \/>\n    u.user_name,<br \/>\n    COUNT(o.order_id) AS order_cnt,<br \/>\n    SUM(o.amount) AS total_amount<br \/>\nFROM users u<br \/>\nLEFT JOIN orders o ON u.user_id &#061; o.user_id AND o.dt &#061; &#039;2026-07-25&#039;<br \/>\nGROUP BY u.user_id, u.user_name;<\/p>\n<h2>10. \u5e76\u884c\u5ea6\u4f18\u5316<\/h2>\n<p>\u5e76\u884c\u5ea6&#xff08;Parallelism&#xff09;\u51b3\u5b9a\u4e86\u4efb\u52a1\u88ab\u62c6\u5206\u6210\u591a\u5c11\u4e2a Task \u5e76\u884c\u6267\u884c&#xff1a;<\/p>\n<ul>\n<li>\u5e76\u884c\u5ea6\u8fc7\u4f4e&#xff1a; \u6bcf\u4e2a Task \u5904\u7406\u6570\u636e\u91cf\u8fc7\u5927&#xff0c;\u6267\u884c\u6162&#xff0c;\u96c6\u7fa4\u8d44\u6e90\u5229\u7528\u4e0d\u5145\u5206<\/li>\n<li>\u5e76\u884c\u5ea6\u8fc7\u9ad8&#xff1a; Task \u6570\u91cf\u8fc7\u591a&#xff0c;\u8c03\u5ea6\u5f00\u9500\u5927&#xff0c;\u4ea7\u751f\u5927\u91cf\u5c0f\u6587\u4ef6&#xff0c;Shuffle \u5143\u6570\u636e\u81a8\u80c0<\/li>\n<\/ul>\n<h3>10.1 Map \u7aef\u5e76\u884c\u5ea6<\/h3>\n<p>Map \u7aef\u5e76\u884c\u5ea6\u7531 \u8f93\u5165\u6587\u4ef6\u7684 Split \u6570\u91cf \u51b3\u5b9a&#xff1a;<\/p>\n<p>&#8212; \u63a7\u5236\u6bcf\u4e2aMap\u5904\u7406\u7684\u6570\u636e\u91cf<br \/>\nSET hive.input.format &#061; org.apache.hadoop.hive.ql.io.CombineHiveInputFormat;<br \/>\n&#8212; \u6bcf\u4e2aSplit\u7684\u6700\u5927\/\u6700\u5c0f\u5927\u5c0f<br \/>\nSET mapreduce.input.fileinputformat.split.maxsize &#061; 256000000;  &#8212; 256MB<br \/>\nSET mapreduce.input.fileinputformat.split.minsize &#061; 128000000;  &#8212; 128MB<\/p>\n<p>&#8212; \u8ba1\u7b97\u516c\u5f0f&#xff1a;<br \/>\n&#8212; Map\u6570\u91cf \u2248 max(1, min(\u914d\u7f6e\u6700\u5927\u6570, \u603b\u6570\u636e\u91cf \/ split_size))<\/p>\n<p>SQL \u793a\u4f8b&#xff1a;<\/p>\n<p>&#8212; \u573a\u666f&#xff1a;100GB\u6570\u636e&#xff0c;\u9ed8\u8ba4128MB\u4e00\u4e2aSplit \u2192 \u7ea6800\u4e2aMap<br \/>\n&#8212; \u5982\u679c\u96c6\u7fa4\u6709200\u4e2aCore&#xff0c;800\u4e2aMap\u9700\u89814\u8f6e\u624d\u80fd\u8dd1\u5b8c<br \/>\n&#8212; \u8c03\u5927Split\u5230512MB \u2192 \u7ea6200\u4e2aMap \u2192 1\u8f6e\u8dd1\u5b8c<\/p>\n<p>SET mapreduce.input.fileinputformat.split.maxsize &#061; 536870912;  &#8212; 512MB<\/p>\n<p>SELECT city, SUM(amount)<br \/>\nFROM orders<br \/>\nWHERE dt &#061; &#039;2026-07-25&#039;<br \/>\nGROUP BY city;<\/p>\n<h3>10.2 Reduce \u7aef\u5e76\u884c\u5ea6<\/h3>\n<p>&#8212; Spark\u5f15\u64ce\u4e0b<br \/>\nSET spark.sql.shuffle.partitions &#061; 200;  &#8212; Shuffle\u540e\u7684\u5206\u533a\u6570&#xff08;\u5373Reduce\u5e76\u884c\u5ea6&#xff09;<\/p>\n<p>SQL \u793a\u4f8b;<\/p>\n<p>&#8212; \u573a\u666f&#xff1a;50GB\u6570\u636e\u505aGroup By<br \/>\n&#8212; \u9ed8\u8ba4200\u4e2aReducer \u2192 \u6bcf\u4e2a\u5904\u7406250MB \u2192 \u5408\u7406<br \/>\n&#8212; \u5982\u679c\u53ea\u670910GB\u6570\u636e \u2192 \u6bcf\u4e2a\u5904\u740650MB \u2192 \u5e76\u884c\u5ea6\u8fc7\u9ad8&#xff0c;\u8c03\u5c0f<\/p>\n<p>SET spark.sql.shuffle.partitions &#061; 50;  &#8212; 10GB \/ 50 &#061; 200MB\/Task<\/p>\n<p>SELECT<br \/>\n    city,<br \/>\n    COUNT(*) AS cnt,<br \/>\n    SUM(amount) AS total<br \/>\nFROM orders<br \/>\nWHERE dt &#061; &#039;2026-07-25&#039;<br \/>\nGROUP BY city;<\/p>\n<h3>10.3 \u5e76\u884c\u5ea6\u4f18\u5316\u7ecf\u9a8c\u516c\u5f0f<\/h3>\n<p>\u63a8\u8350\u5e76\u884c\u5ea6 &#061; \u96c6\u7fa4\u603bCore\u6570 \u00d7 (2~3)<\/p>\n<p>\u793a\u4f8b&#xff1a;<\/p>\n<ul>\n<li>\u96c6\u7fa4&#xff1a;20\u8282\u70b9 \u00d7 8Core &#061; 160 Core<\/li>\n<li>\u63a8\u8350\u5e76\u884c\u5ea6&#xff1a;160 \u00d7 2 &#061; 320 ~ 160 \u00d7 3 &#061; 480<\/li>\n<li>\u8bbe\u7f6e&#xff1a;spark.sql.shuffle.partitions &#061; 400<\/li>\n<li>\u6bcf\u4e2aTask\u5904\u7406\u6570\u636e\u91cf\u5efa\u8bae&#xff1a;128MB ~ 512MB<\/li>\n<\/ul>\n<h3>10.4 \u5b8c\u6574SQL\u793a\u4f8b<\/h3>\n<p>&#8212; \u5927\u4efb\u52a1&#xff1a;100GB\u6570\u636e\u805a\u5408<br \/>\nSET spark.sql.shuffle.partitions &#061; 400;<br \/>\nSET spark.executor.instances &#061; 50;<br \/>\nSET spark.executor.cores &#061; 4;<br \/>\nSET spark.executor.memory &#061; 14g;<\/p>\n<p>SELECT<br \/>\n    dt,<br \/>\n    city,<br \/>\n    category,<br \/>\n    COUNT(*) AS order_cnt,<br \/>\n    SUM(amount) AS total_amount,<br \/>\n    AVG(amount) AS avg_amount<br \/>\nFROM orders<br \/>\nWHERE dt BETWEEN &#039;2026-07-01&#039; AND &#039;2026-07-25&#039;<br \/>\nGROUP BY dt, city, category;<\/p>\n<p>&#8212; \u5c0f\u4efb\u52a1&#xff1a;1GB\u6570\u636e\u67e5\u8be2<br \/>\nSET spark.sql.shuffle.partitions &#061; 20;<\/p>\n<p>SELECT city, COUNT(*) AS cnt<br \/>\nFROM orders<br \/>\nWHERE dt &#061; &#039;2026-07-25&#039;<br \/>\nGROUP BY city;<\/p>\n<h2>11. CBO&#xff08;Cost-Based Optimizer&#xff09;<\/h2>\n<h3>11.1 CBO\u7684\u4f5c\u7528<\/h3>\n<p> \u2460 JOIN \u987a\u5e8f\u4f18\u5316<br \/>\n    \u591a\u8868 JOIN \u65f6&#xff0c;\u51b3\u5b9a\u5148 JOIN \u54ea\u4e24\u5f20\u8868<br \/>\n    \u2192 \u8ba9\u6700\u5c0f\u7684\u4e2d\u95f4\u7ed3\u679c\u5148\u4ea7\u751f&#xff0c;\u907f\u514d\u5927\u8868\u4e4b\u95f4\u5148\u505a\u7b1b\u5361\u5c14\u79ef           <\/p>\n<p> \u2461 JOIN \u7b56\u7565\u9009\u62e9<br \/>\n    \u6839\u636e\u4f30\u7b97\u540e\u7684\u8868\u5927\u5c0f&#xff0c;\u51b3\u5b9a\u7528 Broadcast Join \u8fd8\u662f Shuffle Join<br \/>\n    \u2192 \u5c0f\u8868\u5e7f\u64ad\u96f6 Shuffle&#xff0c;\u5927\u8868\u8d70 Sort-Merge                    <\/p>\n<p> \u2462 \u805a\u5408\u4f4d\u7f6e\u4f18\u5316<br \/>\n    \u51b3\u5b9a GROUP BY \u653e\u5728 JOIN \u524d\u8fd8\u662f JOIN \u540e<br \/>\n    \u2192 \u5148\u805a\u5408\u518d JOIN \u53ef\u5927\u5e45\u51cf\u5c11 Shuffle \u6570\u636e\u91cf                  <\/p>\n<p> \u2463 \u5b50\u67e5\u8be2 \/ \u534a\u8fde\u63a5\u7b56\u7565<br \/>\n    \u51b3\u5b9a IN \u5b50\u67e5\u8be2\u662f\u7269\u5316\u4e3a\u4e34\u65f6\u8868\u505a MapJoin&#xff0c;\u8fd8\u662f\u8d70\u666e\u901a Shuffle<br \/>\n    \u2192 \u5b50\u67e5\u8be2\u7ed3\u679c\u5c0f\u65f6\u7269\u5316\u5e7f\u64ad&#xff0c;\u5927\u65f6\u8d70 Shuffle                    <\/p>\n<h3>11.2 \u53c2\u6570\u8bbe\u7f6e<\/h3>\n<p>&#8212; \u5f00\u542fCBO<br \/>\nSET hive.cbo.enable &#061; true;<br \/>\n&#8212; \u4f7f\u7528\u7edf\u8ba1\u4fe1\u606f\u8ba1\u7b97\u67e5\u8be2(\u5fc5\u987b\u5f00\u542f)<br \/>\nSET hive.compute.query.using.stats &#061; true;<br \/>\n&#8212; \u83b7\u53d6\u5217\u7edf\u8ba1\u4fe1\u606f<br \/>\nSET hive.stats.fetch.column.stats &#061; true;<br \/>\n&#8212; \u83b7\u53d6\u5206\u533a\u7edf\u8ba1\u4fe1\u606f<br \/>\nSET hive.stats.fetch.partition.stats &#061; true;<\/p>\n<p>&#8212; \u6536\u96c6\u8868\u7edf\u8ba1\u4fe1\u606f&#xff08;CBO\u4f9d\u8d56&#xff09;<br \/>\nANALYZE TABLE orders PARTITION(dt&#061;&#039;2026-07-25&#039;) COMPUTE STATISTICS;<br \/>\nANALYZE TABLE orders PARTITION(dt&#061;&#039;2026-07-25&#039;) COMPUTE STATISTICS FOR COLUMNS;<\/p>\n<p>&#8212; CBO\u4f1a\u81ea\u52a8&#xff1a;<br \/>\n&#8212; 1. \u9009\u62e9\u6700\u4f18\u7684Join\u987a\u5e8f&#xff08;\u591a\u8868Join\u65f6&#xff09;<br \/>\n&#8212; 2. \u9009\u62e9\u6700\u4f18\u7684Join\u7b97\u6cd5<br \/>\n&#8212; 3. \u9009\u62e9\u6700\u4f18\u7684\u805a\u5408\u7b56\u7565<\/p>\n<p>\u5230\u8fd9\u91cc&#xff0c;\u4e00\u6761 SQL \u4ece\u8fdb\u5165 Hive \u5230\u843d\u76d8\u8f93\u51fa&#xff0c;\u6cbf\u9014\u80fd\u505a\u7684\u5e38\u89c4\u4f18\u5316\u6211\u4eec\u57fa\u672c\u8d70\u5b8c\u4e86&#xff1a;<br \/>\n\u6267\u884c\u8ba1\u5212\u600e\u4e48\u770b&#xff08;Explain&#xff09;\u2192 \u805a\u5408\u600e\u4e48\u63d0\u524d\u505a&#xff08;Map-side&#xff09;\u2192 \u6570\u636e\u600e\u4e48\u5c11\u8bfb&#xff08;\u5206\u533a\u88c1\u526a \/ \u5217\u88c1\u526a \/ \u8c13\u8bcd\u4e0b\u63a8&#xff09;\u2192 \u8868\u600e\u4e48\u5173\u8054&#xff08;\u56db\u79cd Join \u7b97\u6cd5&#xff09;\u2192 \u6587\u4ef6\u600e\u4e48\u6cbb\u7406&#xff08;\u5c0f\u6587\u4ef6\u5408\u5e76&#xff09;\u2192 \u4efb\u52a1\u600e\u4e48\u5207\u5206&#xff08;\u5e76\u884c\u5ea6&#xff09;\u2192 \u4f18\u5316\u5668\u600e\u4e48\u81ea\u5df1\u9009\u8def&#xff08;CBO&#xff09;<br \/>\n\u8fd9\u4e9b\u624b\u6bb5\u6709\u4e00\u4e2a\u5171\u540c\u70b9&#xff1a;\u5b83\u4eec\u90fd\u662f\u5728 SQL \u771f\u6b63\u8dd1\u8d77\u6765\u4e4b\u524d&#xff0c;\u5c31\u628a\u8ba1\u5212\u5b9a\u6b7b\u4e86\u3002 \u53c2\u6570\u662f\u63d0\u524d\u8bbe\u7684&#xff0c;\u7edf\u8ba1\u4fe1\u606f\u662f\u63d0\u524d\u6536\u96c6\u7684&#xff0c;Join \u987a\u5e8f\u662f\u7f16\u8bd1\u671f\u7b97\u597d\u7684\u3002<br \/>\n\u4f46\u751f\u4ea7\u73af\u5883\u4e0d\u4f1a\u4e56\u4e56\u914d\u5408\u4f60\u7684\u7edf\u8ba1\u4fe1\u606f\u3002<br \/>\n\u4e0b\u4e00\u7bc7\u8981\u89e3\u51b3\u7684\u95ee\u9898<br \/>\n\u5f53&#034;\u63d0\u524d\u89c4\u5212&#034;\u5931\u6548\u7684\u65f6\u5019&#xff0c;\u600e\u4e48\u529e&#xff1f;<br \/>\n\u4e3e\u4e09\u4e2a\u4f60\u4e00\u5b9a\u9047\u5230\u8fc7\u7684\u573a\u666f&#xff1a;<br \/>\n\u573a\u666f\u4e00&#xff1a;\u6570\u636e\u503e\u659c\u3002 \u4f60\u8bbe\u4e86 200 \u4e2a Reduce&#xff0c;199 \u4e2a 3 \u79d2\u8dd1\u5b8c&#xff0c;\u7b2c 200 \u4e2a\u8dd1\u4e86 40 \u5206\u949f\u8fd8\u6ca1\u7ed3\u675f\u2014\u2014\u56e0\u4e3a user_id &#061; -1 \u7684\u810f\u6570\u636e\u6709 2 \u4ebf\u6761&#xff0c;\u5168\u6324\u5728\u4e00\u4e2a Task \u91cc\u3002CBO \u4e0d\u7ba1\u8fd9\u4e2a&#xff0c;spark.sql.shuffle.partitions \u4e5f\u6551\u4e0d\u4e86\u5b83\u3002\u4f60\u9700\u8981\u7684\u662f\u4ece SQL \u5c42\u9762\u628a\u503e\u659c Key \u62c6\u6563&#xff0c;\u6216\u8005\u8ba9\u5f15\u64ce\u8fd0\u884c\u65f6\u81ea\u52a8\u68c0\u6d4b\u5e76\u62c6\u5206\u3002<br \/>\n\u573a\u666f\u4e8c&#xff1a;CBO \u731c\u9519\u4e86\u3002 \u7edf\u8ba1\u4fe1\u606f\u663e\u793a dim_product \u6709 200 \u4e07\u884c&#xff0c;CBO \u8001\u8001\u5b9e\u5b9e\u9009\u4e86 Shuffle Join\u3002\u4f46\u5b9e\u9645\u4e0a\u4e00\u4e2a WHERE category &#061; \u2018electronics\u2019 \u8fc7\u6ee4\u5b8c\u53ea\u5269 3MB\u2014\u2014\u672c\u8be5\u8d70 Broadcast Join&#xff0c;\u767d\u767d\u591a\u4e86\u4e00\u6b21\u5168\u91cf Shuffle\u3002\u7f16\u8bd1\u65f6\u505a\u7684\u51b3\u7b56&#xff0c;\u80fd\u4e0d\u80fd\u8dd1\u7740\u8dd1\u7740\u81ea\u5df1\u6539&#xff1f; \u8fd9\u5c31\u662f AQE&#xff08;Adaptive Query Execution&#xff09;\u8981\u5e72\u7684\u4e8b\u3002<br \/>\n\u573a\u666f\u4e09&#xff1a;\u540c\u6837\u7684 SQL&#xff0c;\u4f60\u7684 Shuffle \u6bd4\u522b\u4eba\u6162 5 \u500d\u3002 \u4e0d\u662f\u8ba1\u5212\u7684\u95ee\u9898&#xff0c;\u4e0d\u662f\u6570\u636e\u91cf\u7684\u95ee\u9898\u2014\u2014\u662f\u5e8f\u5217\u5316\u3002Java \u9ed8\u8ba4\u5e8f\u5217\u5316\u5e26\u7740\u7c7b\u540d\u3001\u5b57\u6bb5\u540d\u3001\u7ee7\u627f\u94fe\u4e00\u8d77\u4f20&#xff0c;\u4f53\u79ef\u81a8\u80c0 5~10 \u500d\u3002\u6362\u6210 Kryo&#xff0c;\u4e00\u4e2a\u53c2\u6570\u7684\u4e8b&#xff0c;Shuffle \u65f6\u95f4\u76f4\u63a5\u780d\u5230\u4e94\u5206\u4e4b\u4e00\u3002\u518d\u5f80\u6df1\u4e86\u8d70&#xff1a;Executor \u5185\u5b58\u600e\u4e48\u5206\u3001Storage \u548c Execution \u5404\u5360\u591a\u5c11\u3001GC \u505c\u987f\u600e\u4e48\u538b\u5230 200ms \u4ee5\u5185\u2014\u2014\u8fd9\u4e9b&#034;\u6700\u540e\u4e00\u516c\u91cc&#034;\u7684\u8c03\u4f18&#xff0c;\u5f80\u5f80\u51b3\u5b9a\u4e86\u4efb\u52a1\u662f\u4ece 15 \u5206\u949f\u53d8\u6210 8 \u5206\u949f&#xff0c;\u8fd8\u662f\u4ece OOM \u53d8\u6210\u8dd1\u901a\u3002<br \/>\n\u4e0b\u4e00\u7bc7&#xff0c;\u6211\u4eec\u628a\u8fd9\u56db\u4ef6\u4e8b\u8bb2\u900f&#xff1a;<\/p>\n<table>\n<tr>\u4e3b\u9898\u6838\u5fc3\u95ee\u9898\u4f60\u4f1a\u62ff\u5230\u4ec0\u4e48<\/tr>\n<tbody>\n<tr>\n<td>\u6570\u636e\u503e\u659c<\/td>\n<td>99% \u7684 Task \u79d2\u5b8c&#xff0c;1% \u7684 Task \u62d6\u6b7b\u6574\u4e2a\u4f5c\u4e1a<\/td>\n<td>5 \u79cd\u5178\u578b\u573a\u666f \u00d7 SQL \u6539\u5199\u65b9\u6848 &#043; 5 \u5957\u53c2\u6570\u65b9\u6848&#xff0c;\u9010\u4e2a\u7ed9\u4ee3\u7801<\/td>\n<\/tr>\n<tr>\n<td>AQE \u81ea\u9002\u5e94\u6267\u884c<\/td>\n<td>\u8ba1\u5212\u662f\u6b7b\u7684&#xff0c;\u6570\u636e\u662f\u6d3b\u7684<\/td>\n<td>\u52a8\u6001\u5408\u5e76\u5206\u533a \/ \u52a8\u6001\u5207\u6362 Join \/ \u81ea\u52a8\u62c6\u5206\u503e\u659c\u2014\u2014\u8fd0\u884c\u65f6&#034;\u6539\u5377&#034;\u7684\u5b8c\u6574\u914d\u7f6e<\/td>\n<\/tr>\n<tr>\n<td>\u5e8f\u5217\u5316<\/td>\n<td>\u540c\u6837\u7684\u6570\u636e&#xff0c;\u4f20\u8f93\u4f53\u79ef\u5dee 10 \u500d<\/td>\n<td>Kryo \u5207\u6362 &#043; Shuffle \u538b\u7f29 &#043; ORC\/Parquet \u5b58\u50a8\u5c42\u9009\u578b<\/td>\n<\/tr>\n<tr>\n<td>\u5185\u5b58\u6a21\u578b &amp; GC<\/td>\n<td>Container killed by YARN \/ OOM \/ GC \u5360\u6bd4 30%&#043;<\/td>\n<td>\u5806\u5185\u5806\u5916\u600e\u4e48\u7b97\u3001Execution vs Storage \u600e\u4e48\u8c03\u3001G1GC \u53c2\u6570\u600e\u4e48\u7ed9<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u6700\u540e\u4f1a\u628a\u4e09\u7bc7\u7684\u5185\u5bb9\u4e32\u6210\u4e00\u4efd\u5b8c\u6574\u7684 ETL \u8c03\u4f18\u6a21\u677f\u2014\u2014\u4ece\u96c6\u7fa4\u914d\u7f6e\u5230 SQL \u6539\u5199\u5230\u8fd0\u884c\u65f6\u53c2\u6570&#xff0c;\u4e00\u4e2a\u6587\u4ef6\u641e\u5b9a&#xff0c;\u62ff\u6765\u5c31\u80fd\u8d34\u8fdb\u751f\u4ea7\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e0a\u4e00\u7bc7\u6211\u4eec\u628a\u96c6\u7fa4\u548c\u5f15\u64ce\u7684\\&#8221;\u786c\u4ef6\u5e95\u5ea7\\&#8221;\u914d\u597d\u4e86\u2014\u2014\u8f66\u9053\u4fee\u5bbd\u3001\u9650\u901f\u8bbe\u5bf9\u3002\u8fd9\u4e00\u7bc7\u5f00\u59cb\u770b\u8f66\u600e\u4e48\u5f00&#xff1a;\u4e00\u6761 SQL \u8fdb\u53bb&#xff0c;Hive \u5148\u628a\u5b83\u62c6\u6210 Stage \u548c Operator&#xff08;\u7b2c 4 \u7ae0&#xff09;&#xff0c;\u7136\u540e\u6211\u4eec\u9010\u4e2a\u73af\u8282\u62a0\u6027\u80fd\u2014\u2014\u805a\u5408\u3001\u88c1\u526a\u3001Join\u3001\u5c0f\u6587\u4ef6\u3001\u5e76\u884c\u5ea6\u3001CBO\u3002\u53c2\u6570\u90fd\u7ed9\u4f60&#xff0c;\u4f46\u66f4\u91cd\u8981\u7684\u662f\u544a\u8bc9\u4f60\u6bcf\u4e2a\u53c2\u6570\u5728\u89e3\u51b3\u6267\u884c\u8ba1\u5212\u91cc\u7684\u54ea\u4e00\u6bb5\u74f6\u9888\u30024. Hive SQL \u6267\u884c\u8ba1\u5212<br \/>\n\u200b\u4f7f\u7528Explain\u53ef\u4ee5\u67e5\u770b Hive SQ<\/p>\n","protected":false},"author":2,"featured_media":91136,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[482,365,768],"topic":[],"class_list":["post-91143","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-hive","tag-spark","tag-sql"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Hive on Spark \u4f01\u4e1a\u7ea7\u8c03\u4f18\uff08\u4e8c\uff09SQL \u4f18\u5316\uff08\u4e0a\uff09\uff1a\u6267\u884c\u8ba1\u5212\u4e0e\u5e38\u89c4\u4f18\u5316 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/91143.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Hive on Spark \u4f01\u4e1a\u7ea7\u8c03\u4f18\uff08\u4e8c\uff09SQL \u4f18\u5316\uff08\u4e0a\uff09\uff1a\u6267\u884c\u8ba1\u5212\u4e0e\u5e38\u89c4\u4f18\u5316 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u4e0a\u4e00\u7bc7\u6211\u4eec\u628a\u96c6\u7fa4\u548c\u5f15\u64ce\u7684&quot;\u786c\u4ef6\u5e95\u5ea7&quot;\u914d\u597d\u4e86\u2014\u2014\u8f66\u9053\u4fee\u5bbd\u3001\u9650\u901f\u8bbe\u5bf9\u3002\u8fd9\u4e00\u7bc7\u5f00\u59cb\u770b\u8f66\u600e\u4e48\u5f00&#xff1a;\u4e00\u6761 SQL \u8fdb\u53bb&#xff0c;Hive \u5148\u628a\u5b83\u62c6\u6210 Stage \u548c Operator&#xff08;\u7b2c 4 \u7ae0&#xff09;&#xff0c;\u7136\u540e\u6211\u4eec\u9010\u4e2a\u73af\u8282\u62a0\u6027\u80fd\u2014\u2014\u805a\u5408\u3001\u88c1\u526a\u3001Join\u3001\u5c0f\u6587\u4ef6\u3001\u5e76\u884c\u5ea6\u3001CBO\u3002\u53c2\u6570\u90fd\u7ed9\u4f60&#xff0c;\u4f46\u66f4\u91cd\u8981\u7684\u662f\u544a\u8bc9\u4f60\u6bcf\u4e2a\u53c2\u6570\u5728\u89e3\u51b3\u6267\u884c\u8ba1\u5212\u91cc\u7684\u54ea\u4e00\u6bb5\u74f6\u9888\u30024. Hive SQL \u6267\u884c\u8ba1\u5212 \u200b\u4f7f\u7528Explain\u53ef\u4ee5\u67e5\u770b Hive SQ\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/91143.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-08-06T18:17:14+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260806181707-6a74cfa3e1ab7.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"11 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/91143.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/91143.html\",\"name\":\"Hive on Spark \u4f01\u4e1a\u7ea7\u8c03\u4f18\uff08\u4e8c\uff09SQL \u4f18\u5316\uff08\u4e0a\uff09\uff1a\u6267\u884c\u8ba1\u5212\u4e0e\u5e38\u89c4\u4f18\u5316 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-08-06T18:17:14+00:00\",\"dateModified\":\"2026-08-06T18:17:14+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/91143.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/91143.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/91143.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Hive on Spark \u4f01\u4e1a\u7ea7\u8c03\u4f18\uff08\u4e8c\uff09SQL \u4f18\u5316\uff08\u4e0a\uff09\uff1a\u6267\u884c\u8ba1\u5212\u4e0e\u5e38\u89c4\u4f18\u5316\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Hive on Spark \u4f01\u4e1a\u7ea7\u8c03\u4f18\uff08\u4e8c\uff09SQL \u4f18\u5316\uff08\u4e0a\uff09\uff1a\u6267\u884c\u8ba1\u5212\u4e0e\u5e38\u89c4\u4f18\u5316 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/91143.html","og_locale":"zh_CN","og_type":"article","og_title":"Hive on Spark \u4f01\u4e1a\u7ea7\u8c03\u4f18\uff08\u4e8c\uff09SQL \u4f18\u5316\uff08\u4e0a\uff09\uff1a\u6267\u884c\u8ba1\u5212\u4e0e\u5e38\u89c4\u4f18\u5316 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u4e0a\u4e00\u7bc7\u6211\u4eec\u628a\u96c6\u7fa4\u548c\u5f15\u64ce\u7684\"\u786c\u4ef6\u5e95\u5ea7\"\u914d\u597d\u4e86\u2014\u2014\u8f66\u9053\u4fee\u5bbd\u3001\u9650\u901f\u8bbe\u5bf9\u3002\u8fd9\u4e00\u7bc7\u5f00\u59cb\u770b\u8f66\u600e\u4e48\u5f00&#xff1a;\u4e00\u6761 SQL \u8fdb\u53bb&#xff0c;Hive \u5148\u628a\u5b83\u62c6\u6210 Stage \u548c Operator&#xff08;\u7b2c 4 \u7ae0&#xff09;&#xff0c;\u7136\u540e\u6211\u4eec\u9010\u4e2a\u73af\u8282\u62a0\u6027\u80fd\u2014\u2014\u805a\u5408\u3001\u88c1\u526a\u3001Join\u3001\u5c0f\u6587\u4ef6\u3001\u5e76\u884c\u5ea6\u3001CBO\u3002\u53c2\u6570\u90fd\u7ed9\u4f60&#xff0c;\u4f46\u66f4\u91cd\u8981\u7684\u662f\u544a\u8bc9\u4f60\u6bcf\u4e2a\u53c2\u6570\u5728\u89e3\u51b3\u6267\u884c\u8ba1\u5212\u91cc\u7684\u54ea\u4e00\u6bb5\u74f6\u9888\u30024. Hive SQL \u6267\u884c\u8ba1\u5212 \u200b\u4f7f\u7528Explain\u53ef\u4ee5\u67e5\u770b Hive SQ","og_url":"https:\/\/www.wsisp.com\/helps\/91143.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-08-06T18:17:14+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260806181707-6a74cfa3e1ab7.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"11 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/91143.html","url":"https:\/\/www.wsisp.com\/helps\/91143.html","name":"Hive on Spark \u4f01\u4e1a\u7ea7\u8c03\u4f18\uff08\u4e8c\uff09SQL \u4f18\u5316\uff08\u4e0a\uff09\uff1a\u6267\u884c\u8ba1\u5212\u4e0e\u5e38\u89c4\u4f18\u5316 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-08-06T18:17:14+00:00","dateModified":"2026-08-06T18:17:14+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/91143.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/91143.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/91143.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"Hive on Spark \u4f01\u4e1a\u7ea7\u8c03\u4f18\uff08\u4e8c\uff09SQL \u4f18\u5316\uff08\u4e0a\uff09\uff1a\u6267\u884c\u8ba1\u5212\u4e0e\u5e38\u89c4\u4f18\u5316"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/91143","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=91143"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/91143\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/91136"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=91143"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=91143"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=91143"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=91143"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}