{"id":4981,"date":"2024-02-18T20:21:39","date_gmt":"2024-02-18T12:21:39","guid":{"rendered":"\/?p=4981"},"modified":"2024-02-18T20:30:13","modified_gmt":"2024-02-18T12:30:13","slug":"6-clickhouse%e7%9a%84%e5%a4%8d%e4%b9%a0","status":"publish","type":"post","link":"http:\/\/xinblog.ltd\/?p=4981","title":{"rendered":"6.ClickHouse\u7684\u590d\u4e60"},"content":{"rendered":"<p>ClickHouse\u7684\u590d\u4e60<\/p>\n<ol>\n<li>\n  ClickHouse\u7684\u5e94\u7528\u573a\u666f\u548c\u4f18\u7f3a\u70b9<\/li>\n<\/ol>\n<p>ClinkHouse \u662f\u4e00\u4e2a\u8054\u673a\u5206\u6790\u578b\u6570\u636e\u5e93<\/p>\n<p>\u5e38\u7528\u4e8e\u6570\u636e\u4ee5\u5927\u6279\u91cf\u8fdb\u884c\u63d2\u5165\u7684\u573a\u666f<\/p>\n<p>\u800c\u4e14\u5728\u67e5\u8be2\u7684\u65f6\u5019\u6700\u597d\u53ea\u67e5\u8be2\u67d0\u51e0\u5217\uff0c\u4f46\u662f\u884c\u6570\u636e\u5f88\u591a\u7684\u573a\u666f\u3002<\/p>\n<p>\u5904\u7406\u5355\u4e2a\u67e5\u8be2\u65f6\u9700\u8981\u9ad8\u541e\u5410\u91cf<\/p>\n<p>\u4e0d\u9700\u8981\u4e8b\u52a1\uff0c\u5bf9\u4e8e\u6570\u636e\u4e00\u81f4\u6027\u8981\u6c42\u4e0d\u662f\u7279\u522b\u9ad8<\/p>\n<p>\u90a3\u4e48\u5176\u4f18\u70b9\u5c31\u662f\u652f\u6301\u8fdb\u884c\u884c\u5b58\u50a8\uff0c\u800c\u4e14\u541e\u5410\u91cf\u5de8\u5927<\/p>\n<p>\u5199\u5165\u5927\u6279\u91cf\u6570\u636e\u7684\u65f6\u5019\u975e\u5e38\u5feb<\/p>\n<p>\u5176\u7f3a\u70b9\u5219\u662f\u4e0d\u652f\u6301\u771f\u6b63\u7684\u5220\u9664\u548c\u66f4\u65b0<\/p>\n<p>\u5bf9\u4e8ejoin\u7684\u652f\u6301\u5e76\u4e0d\u597d<\/p>\n<p>\u800c\u4e14\u7531\u4e8e\u91c7\u7528\u4e86\u5e76\u884c\u5904\u7406\uff0c\u5373\u4f7f\u662f\u4e00\u4e2a\u67e5\u8be2\uff0c\u4e5f\u4f1a\u5148\u8fdb\u884c\u5206\u914d\u4e00\u534a\u7684CPU\u8fdb\u884c\u6267\u884c\uff0c\u6240\u4ee5\u5728\u591a\u4e2a\u67e5\u8be2\u5e76\u53d1\u7684\u65f6\u5019\u53ef\u80fd\u7531\u4e8ecpu\u7684\u5206\u914d\u4e0d\u591f\uff0c\u5bfc\u81f4\u8fdb\u884c\u963b\u585e\u3002<\/p>\n<ol>\n<li>\n  ClinkHouse\u7684\u6838\u5fc3\u7279\u6027<\/li>\n<\/ol>\n<p>\u9996\u5148\u662f\u5217\u5b58\u50a8\uff0c\u652f\u6301\u4ece\u5b58\u50a8\u7cfb\u7edf\u4e2d\u53ea\u8bfb\u53d6\u5fc5\u8981\u7684\u5217\u6570\u636e<\/p>\n<p>\u5176\u6b21\u662f\u652f\u6301\u5411\u91cf\u5316\u6267\u884c\uff0c\u6bd4\u8d77\u4f20\u7edf\u7684\u9010\u884c\u8fdb\u884c\u5904\u7406\uff0c\u6027\u80fd\u6d88\u8017\u66f4\u4f4e<\/p>\n<p>\u5bf9\u4e8e\u6587\u4ef6\u5b58\u50a8\uff0c\u5219\u662f\u91c7\u7528\u4e86\u7f16\u7801\u538b\u7f29\uff0c\u6bcf\u4e00\u5217\u7684\u6570\u636e\u5728\u5b58\u50a8\u7684\u65f6\u5019\u90fd\u662f\u7ecf\u8fc7\u6392\u5e8f\u7684\uff0c\u6574\u4f53\u7684\u5c40\u90e8\u89c4\u5f8b\u6027\u5f88\u5f3a\u3002\u800c\u4e14\u5229\u7528LZ4\uff0cSnappy\u7b49\u538b\u7f29\u7b97\u6cd5\u8fdb\u4e00\u6b65\u63d0\u9ad8\u4e86\u538b\u7f29\u6bd4\u3002<\/p>\n<p>\u6700\u540e\u662f\u652f\u6301\u591a\u7d22\u5f15\uff0c\u53ef\u4ee5\u7528\u4e8e\u52a0\u5feb\u67e5\u8be2\u901f\u5ea6\u3002<\/p>\n<ol>\n<li>\n  \u4f7f\u7528ClinkHouse\u7684\u6ce8\u610f\u9879<\/li>\n<\/ol>\n<p>\u9700\u8981\u6ce8\u610f\uff0c\u5982\u679c\u9700\u8981\u5206\u533a\u952e\uff0c\u90a3\u4e48\u5728\u8fdb\u884c\u5206\u533a\u7684\u65f6\u5019\uff0c\u9009\u62e9\u5206\u533a\u952e\u7684\u7c92\u5ea6\u5f88\u91cd\u8981\uff0c\u5982\u679c\u65f6\u95f4\u7684\u8bdd\uff0c\u6700\u597d\u662f\u6309\u7167\u5929\u7c92\u5ea6<\/p>\n<p>\u5176\u6b21\u662f\u6307\u5b9a\u7d22\u5f15\u5217\uff0cclickhouse\u4e2d\u7684\u7d22\u5f15\u5217\u5c31\u662f\u6392\u5e8f\u5217\uff0c\u901a\u8fc7order by\u6307\u5b9a\uff0c\u4e00\u822c\u6765\u8bf4\u662f\u9891\u7387\u8d8a\u9ad8\uff0c\u90a3\u4e48\u5728order by\u4e2d\u8d8a\u9760\u524d\uff0c\u4f46\u662f\u9700\u8981\u6ce8\u610fprimary key\uff0c\u5373\u4e3b\u952e\u9009\u62e9\u7684\u65f6\u5019\u6bd4\u8f83\u53cd\u76f4\u89c9\u3002\u4e0d\u80fd\u76f4\u63a5\u62ff\u7528\u6237ID\u4f5c\u4e3a\u7d22\u5f15\u5217\uff0c\u56e0\u4e3a\u6570\u636e\u91cf\u592a\u5927\u4e86\uff0c\u800cprimary key \u5fc5\u987b\u8981\u5305\u542b\u5728order by\u4e4b\u4e2d\u3002\u6240\u4ee5\u7528\u6237ID\u5e76\u4e0d\u9002\u5408\u505a\u7d22\u5f15\u5217\u3002<\/p>\n<p>\u8fd8\u6709\u5c31\u662f\u5728\u67e5\u8be2\u7684\u65f6\u5019\u9700\u8981\u4e00\u5b9a\u8981\u642d\u914dlimit\u4f7f\u7528\uff0c\u6216\u8005\u914d\u5408where\uff0c\u4e0d\u7136\u592a\u6d6a\u8d39\u6027\u80fd\u4e86\u3002<\/p>\n<p>\u591a\u8868join\u7684\u65f6\u5019\u9700\u8981\u6ee1\u8db3\u5c0f\u8868\u5728\u53f3\u8fb9\u7684\u539f\u5219\uff0c\u56e0\u4e3a\u53f3\u8868\u4f1a\u52a0\u8f7d\u5230\u5185\u5b58\u4e2d\u548c\u5de6\u8868\u8fdb\u884c\u5bf9\u6bd4\u3002<\/p>\n<ol>\n<li>\n  ClickHouse\u7684\u5f15\u64ce\u6709\u54ea\u4e9b\uff1f<\/li>\n<\/ol>\n<p>\u4e00\u822c\u6765\u8bf4\u6709MergeTree\u7cfb\u5217\u5f15\u64ce\uff0cLog\u7cfb\u5217\u7684\u5f15\u64ce\uff0c\u5176\u4ed6\u7cfb\u7edf\u96c6\u6210\u7684\u5f15\u64ce\uff0c\u7279\u6b8a\u7684\u5f15\u64ce<\/p>\n<p>\u6211\u4eec\u8bf4\u4e0bMergeTree\u7cfb\u5217\u5f15\u64ce\uff0c\u5176\u4e2d\u5305\u542bMergeTree\uff0cReplacingMergeTree\uff0cSummingMergeTree\uff0cAggregatingMergeTree<\/p>\n<p>MergeTree\u4e3b\u8981\u662f\u652f\u6301\u6240\u6709ClickHouse\u7684\u6838\u5fc3\u529f\u80fd\uff0c\u652f\u6301\u4e3b\u952e\u6392\u5e8f\uff0c\u652f\u6301\u6570\u636e\u526f\u672c\uff0c\u652f\u6301\u6570\u636e\u91c7\u6837<\/p>\n<ol>\n<li>\n  \u521b\u5efa\u8868\u65f6\u5019\u7684\u6838\u5fc3\u53c2\u6570\u6709<\/li>\n<\/ol>\n<p>\u9996\u5148\u8981\u6307\u5b9aENGINE\uff0c\u660e\u786e\u662f\u54ea\u4e2a\u5f15\u64ce<\/p>\n<p>ORDER BY\uff0c\u662fMerge Tree\u4e2d\u7684\u5fc5\u586b\u9879\uff0c\u4e3b\u8981\u662f\u5728\u4e0d\u8bbe\u7f6e\u4e3b\u952e\u7684\u65f6\u5019\uff0c\u4f1a\u6309\u7167order by\u7684\u5b57\u6bb5\u8fdb\u884c\u6392\u5e8f\u5904\u7406\uff0c\u800c\u4e14\u4e3b\u952e\u4e5f\u8981\u662forder by\u7684\u524d\u7f00\u5b57\u6bb5\u3002<\/p>\n<p>Order by \u53ef\u4ee5\u6307\u4ee3PRIMARY KEY\uff0c\u4e00\u822c\u6211\u4eec\u53ea\u58f0\u660eORDER BY\u5373\u53ef<\/p>\n<p>\u9664\u6b64\u4e4b\u5916\u5c31\u662fPARTITION BY\uff0c\u5206\u533a\u952e<\/p>\n<p>PRIMARY KEY\uff0c\u6307\u5b9a\u4e3b\u952e<\/p>\n<p>TTL\uff0c\u8bbe\u7f6e\u6570\u636e\u7684\u5b58\u6d3b\u65f6\u95f4<\/p>\n","protected":false},"excerpt":{"rendered":"<p>ClickHouse\u7684\u590d\u4e60 C [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[39],"tags":[],"_links":{"self":[{"href":"http:\/\/xinblog.ltd\/index.php?rest_route=\/wp\/v2\/posts\/4981"}],"collection":[{"href":"http:\/\/xinblog.ltd\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/xinblog.ltd\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/xinblog.ltd\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/xinblog.ltd\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4981"}],"version-history":[{"count":1,"href":"http:\/\/xinblog.ltd\/index.php?rest_route=\/wp\/v2\/posts\/4981\/revisions"}],"predecessor-version":[{"id":5005,"href":"http:\/\/xinblog.ltd\/index.php?rest_route=\/wp\/v2\/posts\/4981\/revisions\/5005"}],"wp:attachment":[{"href":"http:\/\/xinblog.ltd\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4981"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/xinblog.ltd\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4981"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/xinblog.ltd\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4981"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}