{"id":18325,"date":"2026-04-29T15:14:38","date_gmt":"2026-04-29T07:14:38","guid":{"rendered":"https:\/\/kbwp.transwarp.cn\/?p=18325"},"modified":"2026-04-29T15:36:35","modified_gmt":"2026-04-29T07:36:35","slug":"orc%e6%99%ae%e9%80%9a%e8%a1%a8-%e9%80%9a%e8%bf%87%e9%87%8d%e5%bb%ba%e8%a1%a8%e8%a7%a3%e5%86%b3%e5%b0%8f%e6%96%87%e4%bb%b6%e9%97%ae%e9%a2%98","status":"publish","type":"post","link":"https:\/\/kbwp.transwarp.cn\/?p=18325","title":{"rendered":"orc\u666e\u901a\u8868 \u901a\u8fc7\u91cd\u5efa\u8868\u89e3\u51b3\u5c0f\u6587\u4ef6\u95ee\u9898"},"content":{"rendered":"<h2>\u6982\u8981\u63cf\u8ff0<\/h2>\n<p>\u5728\u6570\u636e\u6301\u7eed\u5199\u5165\u7684\u8fc7\u7a0b\u4e2d\uff0cORC \u683c\u5f0f\u7684\u666e\u901a\u8868\uff08\u975e\u4e8b\u52a1\u8868\uff09\u53ef\u80fd\u4f1a\u4ea7\u751f\u5927\u91cf\u5c0f\u6587\u4ef6\u3002\u5c0f\u6587\u4ef6\u8fc7\u591a\u4f1a\u5bfc\u81f4\u4ee5\u4e0b\u95ee\u9898\uff1a<\/p>\n<ul>\n<li><strong>\u67e5\u8be2\u6027\u80fd\u4e0b\u964d<\/strong>\uff1a\u8bfb\u53d6\u65f6\u9700\u8981\u6253\u5f00\u5927\u91cf\u6587\u4ef6\uff0c\u589e\u52a0 I\/O \u5f00\u9500\u548c\u8c03\u5ea6\u6210\u672c<\/li>\n<li><strong>NameNode \u538b\u529b\u589e\u5927<\/strong>\uff1aHDFS \u5143\u6570\u636e\u5360\u7528\u8fc7\u591a\u5185\u5b58\uff0c\u5f71\u54cd\u96c6\u7fa4\u7a33\u5b9a\u6027<\/li>\n<li><strong>\u8d44\u6e90\u5229\u7528\u7387\u4f4e<\/strong>\uff1aMap \u4efb\u52a1\u542f\u52a8\u548c\u9500\u6bc1\u9891\u7e41\uff0c\u8ba1\u7b97\u8d44\u6e90\u6d6a\u8d39\u4e25\u91cd<\/li>\n<\/ul>\n<p>\u672c\u6587\u6863\u63d0\u4f9b\u4e00\u79cd\u901a\u8fc7 <strong>\u521b\u5efa\u8fc7\u6e21\u8868\u5e76\u91cd\u65b0\u5bfc\u5165\u6570\u636e<\/strong> \u7684\u65b9\u5f0f\u6765\u5408\u5e76\u5c0f\u6587\u4ef6\u7684\u64cd\u4f5c\u65b9\u6cd5\u3002<\/p>\n<h2>\u8be6\u7ec6\u8bf4\u660e<\/h2>\n<h3>\u6b65\u9aa4\u4e00\uff1a\u521b\u5efa\u8fc7\u6e21\u8868<\/h3>\n<p>\u6839\u636e\u539f\u8868\u7ed3\u6784\u521b\u5efa\u4e00\u5f20\u7ed3\u6784\u76f8\u540c\u7684\u8fc7\u6e21\u8868\uff0c\u7528\u4e8e\u63a5\u6536\u5408\u5e76\u540e\u7684\u6570\u636e\u3002<\/p>\n<pre><code class=\"language-sql\">-- \u8bf7\u5c06 your_db.target_tb \u66ff\u6362\u4e3a\u5b9e\u9645\u7684\u6570\u636e\u5e93\u548c\u8868\u540d\nCREATE TABLE your_db.stage_tb LIKE your_db.target_tb;<\/code><\/pre>\n<blockquote>\n<p><strong>\u8bf4\u660e<\/strong>\uff1a<code>LIKE<\/code> \u8bed\u6cd5\u4f1a\u5b8c\u6574\u590d\u5236\u539f\u8868\u7684\u5217\u5b9a\u4e49\u3001\u5206\u533a\u7ed3\u6784\u548c\u5b58\u50a8\u683c\u5f0f\uff0c\u4e0d\u4f1a\u590d\u5236\u6570\u636e\u3002<\/p>\n<\/blockquote>\n<h3>\u6b65\u9aa4\u4e8c\uff1a\u8bbe\u7f6e\u5408\u5e76\u53c2\u6570\u5e76\u5bfc\u5165\u6570\u636e<\/h3>\n<p>\u5728\u5f53\u524d\u4f1a\u8bdd\u4e2d\u8bbe\u7f6e\u5c0f\u6587\u4ef6\u5408\u5e76\u53c2\u6570\uff0c\u7136\u540e\u5c06\u539f\u8868\u6570\u636e\u91cd\u65b0\u5199\u5165\u8fc7\u6e21\u8868\u3002<\/p>\n<pre><code class=\"language-sql\">-- \u4ee5\u4e0b\u53c2\u6570\u4ec5\u5728\u5f53\u524d\u4f1a\u8bdd\u751f\u6548\uff0c\u4e0d\u4f1a\u5f71\u54cd\u5176\u4ed6\u4f1a\u8bdd\u6216\u4efb\u52a1\nSET ngmr.partition.automerge = true;      -- \u5f00\u542f\u81ea\u52a8\u5408\u5e76\uff0c\u9ed8\u8ba4false \u5173\u95ed\u72b6\u6001\nSET ngmr.partition.mergesize.mb = 200;    -- \u5408\u5e76\u4ee5\u540e\u6bcf\u4e2atask\u6700\u591a\u5904\u7406\u7684\u6570\u636e\u91cf\u5927\u5c0f\uff0c\u9ed8\u8ba48M\nSET mapred.reduce.tasks = 10;             -- \u8bbe\u7f6e Reduce \u4efb\u52a1\u6570\uff0c\u63a7\u5236\u8f93\u51fa\u6587\u4ef6\u6570\u91cf\uff0c\u9ed8\u8ba4-1\uff0c\u7531\u4e0a\u4e0b\u6587\u51b3\u5b9areduce\u6570\u91cf\u3002\n--reduce\u6570\u76ee\u9700\u8981\u8003\u8651\u8868\u662f\u5426\u5206\u533a\uff1a\n--\u975e\u5206\u533a\u8868\uff1a\u4f8b\u5982\uff0c\u8868\u603b\u6570\u636e\u91cf\u7ea6\u4e3a20GB\uff0c\u5219\u53ef\u8bbe\u7f6e\u4e3a100~400\uff0c\u8fd9\u6837\u6570\u636e\u6587\u4ef6\u5927\u5c0f\u80fd\u63a7\u5236\u572850M~200M\uff1b\n--\u5206\u533a\u8868\uff1a\u4f8b\u5982\uff0c\u8868\u603b\u6570\u636e\u91cf\u7ea6\u4e3a20GB\uff0c\u4f46\u7ec6\u5206\u5230\u6bcf\u4e2a\u5206\u533a\u53ea\u67092G\uff0c\u5219\u53ef\u8bbe\u7f6e\u4e3a10~40\uff0c\u8fd9\u6837\u6570\u636e\u6587\u4ef6\u5927\u5c0f\u80fd\u63a7\u5236\u572850M~200M\uff1b\n\nINSERT INTO your_db.stage_tb\nSELECT * FROM your_db.target_tb\nDISTRIBUTE BY {col1};<\/code><\/pre>\n<p><strong>\u5173\u4e8e <code>DISTRIBUTE BY<\/code> \u5217\u7684\u9009\u62e9<\/strong>\uff1a<\/p>\n<p>\u5efa\u8bae\u9009\u62e9\u6e90\u8868\u4e2d<strong>\u5206\u5e03\u8f83\u4e3a\u79bb\u6563\u7684\u5217<\/strong>\uff08\u5982\u552f\u4e00\u952e\u6216\u8fd1\u4f3c\u552f\u4e00\u7684\u5217\uff09\uff0c\u4ee5\u786e\u4fdd\u6700\u7ec8\u5199\u5165\u7684\u6570\u636e\u6587\u4ef6\u5927\u5c0f\u5747\u5300\u3002\u82e5\u8868\u4e2d\u65e0\u5408\u9002\u7684\u79bb\u6563\u5217\uff0c\u53ef\u4f7f\u7528\u591a\u5217\u62fc\u63a5\u7684\u65b9\u5f0f\uff0c\u4f8b\u5982\uff1a<\/p>\n<pre><code class=\"language-sql\">DISTRIBUTE BY id || email || homeaddress<\/code><\/pre>\n<p>\u6267\u884c\u5b8c\u6210\u540e\uff0c\u8bf7\u91cd\u70b9\u68c0\u67e5\u76ee\u6807\u8868\u5728 HDFS \u4e0a\u7684\u6587\u4ef6\u5927\u5c0f\u662f\u5426\u5747\u5300\uff08\u68c0\u67e5\u65b9\u6cd5\u89c1\u6b65\u9aa4\u4e94\uff09\u3002<\/p>\n<h3>\u6b65\u9aa4\u4e09\uff1a\u5907\u4efd\u539f\u8868<\/h3>\n<p>\u5c06\u539f\u8868\u91cd\u547d\u540d\u4e3a\u5907\u4efd\u8868\uff0c\u786e\u4fdd\u6570\u636e\u53ef\u968f\u65f6\u56de\u9000\u3002<\/p>\n<pre><code class=\"language-sql\">ALTER TABLE your_db.target_tb RENAME TO your_db.target_tb_bak;<\/code><\/pre>\n<blockquote>\n<p><strong>\u6ce8\u610f<\/strong>\uff1a\u91cd\u547d\u540d\u64cd\u4f5c\u4f1a\u7acb\u5373\u751f\u6548\uff0c\u8bf7\u786e\u8ba4\u4e0b\u6e38\u4efb\u52a1\uff08\u5982\u5b9a\u65f6\u8c03\u5ea6\u3001ETL \u4f5c\u4e1a\u7b49\uff09\u662f\u5426\u4f9d\u8d56\u8be5\u8868\u540d\u3002\u5982\u6709\u4f9d\u8d56\uff0c\u8bf7\u9009\u62e9\u5408\u9002\u7684\u6267\u884c\u65f6\u95f4\u7a97\u53e3\u3002<\/p>\n<\/blockquote>\n<h3>\u6b65\u9aa4\u56db\uff1a\u66ff\u6362\u76ee\u6807\u8868<\/h3>\n<p>\u5c06\u8fc7\u6e21\u8868\u91cd\u547d\u540d\u4e3a\u76ee\u6807\u8868\uff0c\u5b8c\u6210\u8868\u66ff\u6362\u3002<\/p>\n<pre><code class=\"language-sql\">ALTER TABLE your_db.stage_tb RENAME TO your_db.target_tb;<\/code><\/pre>\n<h3>\u6b65\u9aa4\u4e94\uff1a\u9a8c\u8bc1\u4e0e\u6e05\u7406<\/h3>\n<ul>\n<li>\n<p>\u901a\u8fc7hdfs\u547d\u4ee4\u68c0\u67e5\u5c0f\u6587\u4ef6\u6570\u91cf\u3001\u5927\u5c0f\u662f\u5426\u5747\u5300<\/p>\n<pre><code class=\"language-sql\">hdfs dfs -count \/path\/to\/table\/dir<\/code><\/pre>\n<\/li>\n<li>\n<p>\u6267\u884c <code>SELECT COUNT(*)<\/code> \u5bf9\u6bd4\u539f\u8868\u4e0e\u5408\u5e76\u540e\u8868\u7684\u884c\u6570\u662f\u5426\u4e00\u81f4\u3002<\/p>\n<\/li>\n<li>\n<p>\u62bd\u6837\u68c0\u67e5\u6570\u636e\u5185\u5bb9\u662f\u5426\u6b63\u786e\u3002<\/p>\n<\/li>\n<\/ul>\n<p>\u786e\u8ba4\u6570\u636e\u65e0\u8bef\u540e\uff0c\u5220\u9664\u5907\u4efd\u8868\u3002<strong>\u5efa\u8bae\u89c2\u5bdf\u81f3\u5c11\u4e00\u4e2a\u6708\u540e\u518d\u505a\u6e05\u7406<\/strong>\uff0c\u4ee5\u786e\u4fdd\u4e0b\u6e38\u6240\u6709\u4efb\u52a1\u6b63\u5e38\u8fd0\u884c\uff1a<\/p>\n<pre><code class=\"language-sql\">DROP TABLE IF EXISTS your_db.target_tb_bak;<\/code><\/pre>\n<hr \/>\n<h2>\u6839\u672c\u89e3\u51b3\u65b9\u6848<\/h2>\n<p>\u4ee5\u4e0a\u65b9\u6cd5\u901a\u8fc7\u91cd\u5efa\u8868\u6765\u91cd\u65b0\u7ec4\u7ec7\u6570\u636e\uff0c\u80fd\u6709\u6548\u5408\u5e76\u5c0f\u6587\u4ef6\uff0c\u4f46\u65e0\u6cd5\u4ece\u6e90\u5934\u907f\u514d\u5c0f\u6587\u4ef6\u7684\u6301\u7eed\u4ea7\u751f\u3002\u8981\u4ece\u6839\u672c\u4e0a\u89e3\u51b3\u5c0f\u6587\u4ef6\u95ee\u9898\uff0c\u5efa\u8bae\u5c06\u8868\u91cd\u5efa\u4e3a <strong>ORC \u4e8b\u52a1\u8868\uff08TORC\uff09<\/strong>\uff0c\u8be5\u8868\u7c7b\u578b\u652f\u6301\u540e\u53f0\u81ea\u52a8\u5408\u5e76\u5c0f\u6587\u4ef6\uff0c\u65e0\u9700\u4eba\u5de5\u5e72\u9884\u3002<\/p>\n<p>\u5982\u9700\u4e86\u89e3\u4e8b\u52a1\u8868\u7684\u521b\u5efa\u65b9\u5f0f\uff0c\u8bf7\u8054\u7cfb\u6280\u672f\u652f\u6301\u56e2\u961f\u83b7\u53d6\u8be6\u7ec6\u6307\u5bfc\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6982\u8981\u63cf\u8ff0 \u5728\u6570\u636e\u6301\u7eed\u5199\u5165\u7684\u8fc7\u7a0b\u4e2d\uff0cORC \u683c\u5f0f\u7684\u666e\u901a\u8868\uff08\u975e\u4e8b\u52a1\u8868\uff09\u53ef\u80fd\u4f1a\u4ea7\u751f\u5927\u91cf\u5c0f\u6587\u4ef6\u3002\u5c0f\u6587\u4ef6\u8fc7\u591a\u4f1a\u5bfc\u81f4\u4ee5\u4e0b\u95ee ..<\/p>\n<div class=\"clear-fix\"><\/div>\n<p><a href=\"https:\/\/kbwp.transwarp.cn\/?p=18325\" title=\"read more...\">Read more<\/a><\/p>\n","protected":false},"author":12,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-18325","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"acf":[],"_links":{"self":[{"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/posts\/18325","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/users\/12"}],"replies":[{"embeddable":true,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=18325"}],"version-history":[{"count":3,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/posts\/18325\/revisions"}],"predecessor-version":[{"id":18332,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/posts\/18325\/revisions\/18332"}],"wp:attachment":[{"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=18325"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=18325"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=18325"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}