{"id":237434,"date":"2022-03-24T10:30:52","date_gmt":"2022-03-24T02:30:52","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=237434"},"modified":"2022-03-11T11:32:05","modified_gmt":"2022-03-11T03:32:05","slug":"citus-of-distributed-postgresql","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/citus-of-distributed-postgresql.html","title":{"rendered":"\u5206\u5e03\u5f0fPostgreSQL\u4e4bCitus"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u6bcf\u4e2acluster\u90fd\u6709\u4e00\u4e2a\u79f0\u4e3acoordinator(\u534f\u8c03\u5668) \u7684\u7279\u6b8a\u8282\u70b9\uff08\u5176\u4ed6\u8282\u70b9\u79f0\u4e3a worker\u8282\u70b9\uff09\u3002\u5e94\u7528\u7a0b\u5e8f\u5c06\u5b83\u4eec\u7684\u67e5\u8be2\u53d1\u9001\u5230coordinator\u8282\u70b9\uff0ccoordinator\u8282\u70b9\u5c06\u5176\u8f6c\u53d1\u7ed9\u76f8\u5173\u7684worker\u5e76\u7d2f\u79ef\u7ed3\u679c\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
\u8282\u70b9<\/strong><\/div>\n

Citus \u662f\u4e00\u79cd PostgreSQL \u6269\u5c55\uff0c\u5b83\u5141\u8bb8\u6570\u636e\u5e93\u670d\u52a1\u5668(\u79f0\u4e3a\u8282\u70b9)\u5728\u201c\u65e0\u5171\u4eab(shared nothing)\u201d\u67b6\u6784\u4e2d\u76f8\u4e92\u534f\u8c03\u3002\u8fd9\u4e9b\u8282\u70b9\u5f62\u6210\u4e00\u4e2a\u96c6\u7fa4\uff0c\u5141\u8bb8 PostgreSQL \u4fdd\u5b58\u6bd4\u5355\u53f0\u8ba1\u7b97\u673a\u4e0a\u66f4\u591a\u7684\u6570\u636e\u548c\u4f7f\u7528\u66f4\u591a\u7684 CPU \u5185\u6838\u3002\u8fd9\u79cd\u67b6\u6784\u8fd8\u5141\u8bb8\u901a\u8fc7\u7b80\u5355\u5730\u5411\u96c6\u7fa4\u6dfb\u52a0\u66f4\u591a\u8282\u70b9\u6765\u6269\u5bb9\u6570\u636e\u5e93\u3002<\/p>\n

\u6269\u5c55:https:\/\/www.postgresql.org\/docs\/current\/external-extensions.html<\/p>\n

Coordinator \u4e0e Worker<\/strong><\/span><\/div>\n

\u6bcf\u4e2a cluster \u90fd\u6709\u4e00\u4e2a\u79f0\u4e3a coordinator(\u534f\u8c03\u5668) \u7684\u7279\u6b8a\u8282\u70b9(\u5176\u4ed6\u8282\u70b9\u79f0\u4e3a worker \u8282\u70b9)\u3002\u5e94\u7528\u7a0b\u5e8f\u5c06\u5b83\u4eec\u7684\u67e5\u8be2\u53d1\u9001\u5230 coordinator \u8282\u70b9\uff0ccoordinator \u8282\u70b9\u5c06\u5176\u8f6c\u53d1\u7ed9\u76f8\u5173\u7684 worker \u5e76\u7d2f\u79ef\u7ed3\u679c\u3002<\/p>\n

\u5bf9\u4e8e\u6bcf\u4e2a\u67e5\u8be2\uff0ccoordinator \u8981\u4e48\u5c06\u5176\u8def\u7531\u5230\u5355\u4e2a worker \u8282\u70b9\uff0c\u8981\u4e48\u5c06\u5176\u5e76\u884c\u5316\u5230\u591a\u4e2a\u8282\u70b9\uff0c\u5177\u4f53\u53d6\u51b3\u4e8e\u6240\u9700\u6570\u636e\u662f\u4f4d\u4e8e\u5355\u4e2a\u8282\u70b9\u4e0a\u8fd8\u662f\u591a\u4e2a\u8282\u70b9\u4e0a\u3002coordinator \u901a\u8fc7\u67e5\u9605\u5176\u5143\u6570\u636e\u8868\u77e5\u9053\u5982\u4f55\u505a\u5230\u8fd9\u4e00\u70b9\u3002\u8fd9\u4e9b Citus \u7279\u5b9a\u8868\u8ddf\u8e2a worker \u8282\u70b9\u7684 DNS \u540d\u79f0\u548c\u8fd0\u884c\u72b6\u51b5\uff0c\u4ee5\u53ca\u8de8\u8282\u70b9\u6570\u636e\u7684\u5206\u5e03\u60c5\u51b5\u3002<\/p>\n

\u5206\u5e03\u5f0f\u6570\u636e<\/strong><\/div>\n

Citus \u96c6\u7fa4\u4e2d\u6709\u4e09\u79cd\u7c7b\u578b\u7684\u8868\uff0c\u6bcf\u79cd\u8868\u90fd\u4ee5\u4e0d\u540c\u65b9\u5f0f\u5b58\u50a8\u5728\u8282\u70b9\u4e2d\uff0c\u5e76\u4e14\u7528\u4e8e\u4e0d\u540c\u7684\u76ee\u7684\u3002<\/p>\n

\u7c7b\u578b 1\uff1a\u5206\u5e03\u5f0f\u8868<\/strong><\/span><\/div>\n

\u7b2c\u4e00\u79cd\u7c7b\u578b\uff0c\u4e5f\u662f\u6700\u5e38\u89c1\u7684\uff0c\u662f\u5206\u5e03\u5f0f\u8868\u3002\u5bf9\u4e8e SQL \u8bed\u53e5\u800c\u8a00\uff0c\u5b83\u4eec\u770b\u4f3c\u662f\u666e\u901a\u7684\u8868\uff0c\u4f46\u5728 worker \u8282\u70b9\u4e4b\u95f4\u6c34\u5e73\u5206\u533a\u3002<\/p>\n

\"\"<\/p>\n

\u8fd9\u91cc table \u7684\u884c\u5b58\u50a8\u5728 worker \u7684\u8868 table_1001\u3001table_1002 \u7b49\u4e2d\u3002\u7ec4\u4ef6 worker \u8868\u79f0\u4e3a\u5206\u7247(shards)\u3002<\/p>\n

Citus \u4f7f\u7528\u4f7f\u7528\u5206\u7247\u7b97\u6cd5\u5c06\u884c\u5206\u914d\u5230\u5206\u7247\u3002\u57fa\u4e8e\u8868\u5217(\u79f0\u4e3a\u5206\u5e03\u5217(distribution column))\u7684\u503c\u6267\u884c\u5206\u914d\uff0c\u6b64\u5206\u914d\u5177\u6709\u786e\u5b9a\u6027\u3002\u96c6\u7fa4\u7ba1\u7406\u5458\u5728\u5206\u5e03\u8868\u65f6\u5fc5\u987b\u6307\u5b9a\u6b64\u5217\u3002\u505a\u51fa\u6b63\u786e\u7684\u9009\u62e9\uff0c\u8fd9\u4e00\u70b9\u5bf9\u4e8e\u6027\u80fd\u548c\u529f\u80fd\u6709\u91cd\u8981\u5f71\u54cd\u3002<\/p>\n

\u7c7b\u578b 2\uff1a\u5f15\u7528\u8868<\/strong><\/span><\/div>\n

\u5f15\u7528\u8868 \u662f\u4e00\u79cd\u5206\u5e03\u5f0f\u8868\uff0c\u5176\u5168\u90e8\u5185\u5bb9\u90fd\u96c6\u4e2d\u5230\u5355\u4e2a\u5206\u7247\u4e2d\uff0c\u5e76\u5728\u6bcf\u4e2a worker \u4e0a\u590d\u5236\u3002\u56e0\u6b64\uff0c\u5bf9\u4efb\u4f55 worker \u7684\u67e5\u8be2\u90fd\u53ef\u4ee5\u5728\u672c\u5730\u8bbf\u95ee \u5f15\u7528 \u4fe1\u606f\uff0c\u65e0\u9700\u4ece\u53e6\u4e00\u4e2a\u8282\u70b9\u8bf7\u6c42\u884c\uff0c\u56e0\u6b64\u4e5f\u4e0d\u4f1a\u4ea7\u751f\u6b64\u7c7b\u7f51\u7edc\u5f00\u9500\u3002\u5f15\u7528\u8868\u6ca1\u6709\u5206\u5e03\u5217\uff0c\u56e0\u4e3a\u65e0\u9700\u533a\u5206\u6bcf\u884c\u7684\u5404\u4e2a\u5206\u7247\u3002<\/p>\n

\u5f15\u7528\u8868 \u901a\u5e38\u5f88\u5c0f\uff0c\u7528\u4e8e\u5b58\u50a8\u4e0e\u5728\u4efb\u4f55\u5de5\u4f5c\u8282\u70b9\u4e0a\u8fd0\u884c\u7684\u67e5\u8be2\u76f8\u5173\u7684\u6570\u636e\u3002\u4f8b\u5982\uff0c\u8ba2\u5355\u72b6\u6001\u6216\u4ea7\u54c1\u7c7b\u522b\u7b49\u679a\u4e3e\u503c\u3002<\/p>\n

\u5f53\u4e0e \u5f15\u7528\u8868 \u4ea4\u4e92\u65f6\uff0c\u6211\u4eec\u4f1a\u81ea\u52a8\u5bf9\u4e8b\u52a1\u6267\u884c\u4e24\u9636\u6bb5\u63d0\u4ea4 (2PC)\u3002\u8fd9\u610f\u5473\u7740 Citus \u786e\u4fdd\u60a8\u7684\u6570\u636e\u59cb\u7ec8\u5904\u4e8e\u4e00\u81f4\u72b6\u6001\uff0c\u65e0\u8bba\u60a8\u662f\u5728\u5199\u5165\u3001\u4fee\u6539\u8fd8\u662f\u5220\u9664\u5b83\u3002<\/p>\n

2PC:https:\/\/en.wikipedia.org\/wiki\/Two-phase_commit_protocol<\/p>\n

\u7c7b\u578b 3\uff1a\u672c\u5730\u8868<\/strong><\/span><\/div>\n

\u5f53\u60a8\u4f7f\u7528 Citus \u65f6\uff0c\u60a8\u8fde\u63a5\u5e76\u4e0e\u4e4b\u4ea4\u4e92\u7684 coordinator \u8282\u70b9\u662f\u5b89\u88c5\u4e86 Citus \u6269\u5c55\u7684\u5e38\u89c4 PostgreSQL \u6570\u636e\u5e93\u3002\u56e0\u6b64\uff0c\u60a8\u53ef\u4ee5\u521b\u5efa\u666e\u901a\u8868\u5e76\u9009\u62e9\u4e0d\u5bf9\u5176\u8fdb\u884c\u5206\u7247\u3002\u8fd9\u5bf9\u4e8e\u4e0d\u53c2\u4e0e\u8fde\u63a5\u67e5\u8be2\u7684\u5c0f\u578b\u7ba1\u7406\u8868\u5f88\u6709\u7528\u3002\u4e00\u4e2a\u793a\u4f8b\u662f\u7528\u4e8e\u5e94\u7528\u7a0b\u5e8f\u767b\u5f55\u548c\u8eab\u4efd\u9a8c\u8bc1\u7684\u7528\u6237\u8868\u3002<\/p>\n

\u521b\u5efa\u6807\u51c6 PostgreSQL \u8868\u5f88\u5bb9\u6613\uff0c\u56e0\u4e3a\u5b83\u662f\u9ed8\u8ba4\u503c\u3002\u8fd9\u662f\u4f60\u8fd0\u884c CREATE TABLE \u65f6\u5f97\u5230\u7684\u3002\u5728\u51e0\u4e4e\u6bcf\u4e2a Citus \u90e8\u7f72\u4e2d\uff0c\u6211\u4eec\u90fd\u4f1a\u770b\u5230\u6807\u51c6 PostgreSQL \u8868\u4e0e distributed \u548c reference \u8868\u5171\u5b58\u3002\u4e8b\u5b9e\u4e0a\uff0c\u5982\u524d\u6240\u8ff0\uff0cCitus \u672c\u8eab\u4f7f\u7528\u672c\u5730\u8868\u6765\u4fdd\u5b58\u96c6\u7fa4\u5143\u6570\u636e\u3002<\/p>\n

Shards<\/strong><\/span><\/div>\n

\u4e0a\u4e00\u8282\u5c06\u5206\u7247\u63cf\u8ff0\u4e3a\u5728 worker \u8282\u70b9\u5185\u7684\u8f83\u5c0f\u8868\u4e2d\u5305\u542b\u5206\u5e03\u5f0f\u8868\u7684\u884c\u7684\u5b50\u96c6\u3002\u672c\u8282\u8be6\u7ec6\u4ecb\u7ecd\u4e86\u6280\u672f\u7ec6\u8282\u3002<\/p>\n

\u534f\u8c03\u5668\u4e0a\u7684 pg_dist_shard \u5143\u6570\u636e\u8868\u5305\u542b\u7cfb\u7edf\u4e2d\u6bcf\u4e2a\u5206\u5e03\u5f0f\u8868\u7684\u6bcf\u4e2a\u5206\u7247\u7684\u884c\u3002\u8be5\u884c\u4e0e\u5206\u7247 ID \u76f8\u5339\u914d\uff0c\u5206\u7247 ID \u7684\u8303\u56f4\u662f\u4e00\u7ec4\u54c8\u5e0c\u6574\u6570 (shardminvalue, shardmaxvalue)\u3002<\/p>\n

\r\nSELECT * from pg_dist_shard;\r\n logicalrelid  | shardid | shardstorage | shardminvalue | shardmaxvalue\r\n---------------+---------+--------------+---------------+---------------\r\n github_events |  102026 | t            | 268435456     | 402653183\r\n github_events |  102027 | t            | 402653184     | 536870911\r\n github_events |  102028 | t            | 536870912     | 671088639\r\n github_events |  102029 | t            | 671088640     | 805306367\r\n (4 rows)\r\n<\/pre>\n

\u5982\u679c coordinator \u8282\u70b9\u8981\u786e\u5b9a\u54ea\u4e2a\u5206\u7247\u5305\u542b github_events \u884c\uff0c\u5b83\u5c06\u5bf9\u884c\u4e2d\u5206\u5e03\u5217\u7684\u503c\u6267\u884c\u54c8\u5e0c\u7b97\u6cd5\u3002\u7136\u540e\u6b64\u8282\u70b9\u68c0\u67e5\u54ea\u4e2a\u5206\u7247\u7684\u8303\u56f4\u5305\u542b\u6b64\u54c8\u5e0c\u503c\u3002\u5b9a\u4e49\u8303\u56f4\u540e\uff0c\u54c8\u5e0c\u51fd\u6570\u7684image(\u56fe\u50cf)\u5c31\u662f\u4e24\u8005\u7684\u5e76\u67e5\u3002<\/p>\n

\u5206\u7247\u653e\u7f6e<\/strong><\/span><\/div>\n

\u5047\u8bbe\u5206\u7247 102027 \u4e0e\u76f8\u5e94\u7684\u884c\u5173\u8054\u3002\u5728\u67d0\u4e2a worker \u4e2d\u7684 github_events_102027 \u8868\u4e2d\u8bfb\u53d6\u6216\u5199\u5165\u6b64\u884c\u3002\u662f\u54ea\u4e2a worker?\u8fd9\u5b8c\u5168\u7531\u5143\u6570\u636e\u8868\u786e\u5b9a\u3002\u5206\u7247\u6620\u5c04\u5230 worker \u7684\u8fc7\u7a0b\u79f0\u4e3a\u5206\u7247\u653e\u7f6e(shard placement)\u3002<\/p>\n

coordinator \u8282\u70b9\u5c06\u67e5\u8be2\u91cd\u5199\u4e3a\u5f15\u7528\u7279\u5b9a\u8868(\u4f8b\u5982 github_events_102027)\u7684\u7247\u6bb5\uff0c\u5e76\u5bf9\u76f8\u5e94 worker \u8fd0\u884c\u8fd9\u4e9b\u7247\u6bb5\u3002\u4e0b\u9762\u7684\u67e5\u8be2\u793a\u4f8b\u5728\u540e\u53f0\u8fd0\u884c\uff0c\u65e8\u5728\u67e5\u627e\u5206\u7247 ID \u4e3a 102027 \u7684\u8282\u70b9\u3002<\/p>\n

\r\nSELECT\r\n    shardid,\r\n    node.nodename,\r\n    node.nodeport\r\nFROM pg_dist_placement placement\r\nJOIN pg_dist_node node\r\n  ON placement.groupid = node.groupid\r\n AND node.noderole = 'primary'::noderole\r\nWHERE shardid = 102027;\r\n\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\r\n\u2502 shardid \u2502 nodename  \u2502 nodeport \u2502\r\n\u251c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524\r\n\u2502  102027 \u2502 localhost \u2502     5433 \u2502\r\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\r\n<\/pre>\n

\u5728 github_events \u793a\u4f8b\u4e2d\uff0c\u6709\u56db\u4e2a\u5206\u7247\u3002\u6bcf\u4e2a\u8868\u7684\u5206\u7247\u6570\u91cf\u5728\u5176\u5728\u96c6\u7fa4\u4e2d\u5206\u5e03\u65f6\u662f\u53ef\u914d\u7f6e\u7684\u3002<\/p>\n

\u6700\u540e\u8bf7\u6ce8\u610f\uff0cCitus \u5141\u8bb8\u590d\u5236\u5206\u7247\u4ee5\u9632\u6b62\u6570\u636e\u4e22\u5931\u3002\u6709\u4e24\u79cd\u590d\u5236\u201c\u6a21\u5f0f\u201d\uff1aCitus \u590d\u5236\u548c\u6d41\u590d\u5236\u3002\u524d\u8005\u521b\u5efa\u989d\u5916\u7684\u5907\u4efd\u5206\u7247\u653e\u7f6e\u5e76\u9488\u5bf9\u6240\u6709\u66f4\u65b0\u5b83\u4eec\u7684\u6240\u6709\u5b83\u4eec\u8fd0\u884c\u67e5\u8be2\u3002\u540e\u8005\u6548\u7387\u66f4\u9ad8\uff0c\u5229\u7528 PostgreSQL \u7684\u6d41\u5f0f\u590d\u5236\u5c06\u6bcf\u4e2a\u8282\u70b9\u7684\u6574\u4e2a\u6570\u636e\u5e93\u5907\u4efd\u5230\u4e00\u4e2a follower \u6570\u636e\u5e93\u3002\u8fd9\u662f\u900f\u660e\u7684\uff0c\u4e0d\u9700\u8981 Citus \u5143\u6570\u636e\u8868\u7684\u53c2\u4e0e\u3002<\/p>\n

\u5171\u7f6e<\/strong><\/span><\/div>\n

\u7531\u4e8e\u53ef\u4ee5\u6839\u636e\u9700\u8981\u5c06\u5206\u7247\u53ca\u5176\u526f\u672c\u653e\u7f6e\u5728\u8282\u70b9\u4e0a\uff0c\u56e0\u6b64\u5c06\u5305\u542b\u76f8\u5173\u8868\u7684\u76f8\u5173\u884c\u7684\u5206\u7247\u653e\u5728\u540c\u4e00\u8282\u70b9\u4e0a\u662f\u6709\u610f\u4e49\u7684\u3002\u8fd9\u6837\uff0c\u5b83\u4eec\u4e4b\u95f4\u7684\u8fde\u63a5\u67e5\u8be2\u53ef\u4ee5\u907f\u514d\u901a\u8fc7\u7f51\u7edc\u53d1\u9001\u5c3d\u53ef\u80fd\u591a\u7684\u4fe1\u606f\uff0c\u5e76\u4e14\u53ef\u4ee5\u5728\u5355\u4e2a Citus \u8282\u70b9\u5185\u6267\u884c\u3002<\/p>\n

\u4e00\u4e2a\u793a\u4f8b\u662f\u5305\u542b\u5546\u5e97\u3001\u4ea7\u54c1\u548c\u8d2d\u4e70\u7684\u6570\u636e\u5e93\u3002\u5982\u679c\u6240\u6709\u4e09\u4e2a\u8868\u90fd\u5305\u542b - \u5e76\u4e14\u7531 - store_id \u5217\u5206\u5e03\uff0c\u90a3\u4e48\u9650\u5236\u5728\u5355\u4e2a\u5b58\u50a8\u4e2d\u7684\u6240\u6709\u67e5\u8be2\u90fd\u53ef\u4ee5\u5728\u5355\u4e2a\u5de5\u4f5c\u8282\u70b9\u4e0a\u9ad8\u6548\u8fd0\u884c\u3002\u5373\u4f7f\u67e5\u8be2\u6d89\u53ca\u8fd9\u4e9b\u8868\u7684\u4efb\u610f\u7ec4\u5408\u4e5f\u662f\u5982\u6b64\u3002<\/p>\n

\u5e76\u884c\u6027<\/strong><\/span><\/div>\n

\u8de8\u591a\u53f0\u673a\u5668\u5206\u6563\u67e5\u8be2\u5141\u8bb8\u4e00\u6b21\u8fd0\u884c\u66f4\u591a\u67e5\u8be2\uff0c\u5e76\u5141\u8bb8\u901a\u8fc7\u5411\u96c6\u7fa4\u6dfb\u52a0\u65b0\u673a\u5668\u6765\u6269\u5c55\u5904\u7406\u901f\u5ea6\u3002\u6b64\u5916\uff0c\u5982\u4e0a\u4e00\u8282\u6240\u8ff0\uff0c\u5c06\u5355\u4e2a\u67e5\u8be2\u62c6\u5206\u4e3a\u7247\u6bb5\u53ef\u4ee5\u63d0\u9ad8\u4e13\u7528\u4e8e\u5b83\u7684\u5904\u7406\u80fd\u529b\u3002\u540e\u4e00\u79cd\u60c5\u51b5\u5b9e\u73b0\u4e86\u6700\u5927\u7684\u5e76\u884c\u6027\uff0c\u8fd9\u610f\u5473\u7740 CPU \u5185\u6838\u7684\u5229\u7528\u7387\u3002<\/p>\n

\u8bfb\u53d6\u6216\u5f71\u54cd\u5747\u5300\u5206\u5e03\u5728\u591a\u4e2a\u8282\u70b9\u4e0a\u7684\u5206\u7247\u7684\u67e5\u8be2\u80fd\u591f\u4ee5\u201c\u5b9e\u65f6\u201d\u901f\u5ea6\u8fd0\u884c\u3002\u8bf7\u6ce8\u610f\uff0c\u67e5\u8be2\u7684\u7ed3\u679c\u4ecd\u7136\u9700\u8981\u901a\u8fc7\u534f\u8c03\u5668\u8282\u70b9\u4f20\u56de\uff0c\u56e0\u6b64\u5f53\u6700\u7ec8\u7ed3\u679c\u7d27\u51d1\u65f6(\u4f8b\u5982\u8ba1\u6570\u548c\u63cf\u8ff0\u6027\u7edf\u8ba1\u7b49\u805a\u5408\u51fd\u6570)\uff0c\u52a0\u901f\u6548\u679c\u6700\u4e3a\u660e\u663e\u3002<\/p>\n

\u67e5\u8be2\u6267\u884c<\/strong><\/div>\n
<\/strong><\/div>\n

\u5728\u6267\u884c\u591a\u5206\u7247\u67e5\u8be2\u65f6\uff0cCitus \u5fc5\u987b\u5e73\u8861\u5e76\u884c\u6027\u7684\u6536\u76ca\u4e0e\u6570\u636e\u5e93\u8fde\u63a5\u7684\u5f00\u9500(\u7f51\u7edc\u5ef6\u8fdf\u548c\u5de5\u4f5c\u8282\u70b9\u8d44\u6e90\u4f7f\u7528)\u3002\u8981\u914d\u7f6e Citus \u7684\u67e5\u8be2\u6267\u884c\u4ee5\u83b7\u5f97\u6700\u4f73\u7684\u6570\u636e\u5e93\u5de5\u4f5c\u8d1f\u8f7d\u7ed3\u679c\uff0c\u5b83\u6709\u52a9\u4e8e\u4e86\u89e3 Citus \u5982\u4f55\u7ba1\u7406\u548c\u4fdd\u5b58\u534f\u8c03\u8282\u70b9\u548c\u5de5\u4f5c\u8282\u70b9\u4e4b\u95f4\u7684\u6570\u636e\u5e93\u8fde\u63a5\u3002<\/p>\n

Citus \u5c06\u6bcf\u4e2a\u4f20\u5165\u7684\u591a\u5206\u7247\u67e5\u8be2\u4f1a\u8bdd\u8f6c\u6362\u4e3a\u79f0\u4e3a\u4efb\u52a1\u7684\u6bcf\u4e2a\u5206\u7247\u67e5\u8be2\u3002\u5b83\u5c06\u4efb\u52a1\u6392\u961f\uff0c\u5e76\u5728\u80fd\u591f\u83b7\u5f97\u4e0e\u76f8\u5173\u5de5\u4f5c\u8282\u70b9\u7684\u8fde\u63a5\u65f6\u8fd0\u884c\u5b83\u4eec\u3002\u5bf9\u4e8e\u5206\u5e03\u5f0f\u8868 foo \u548c bar \u7684\u67e5\u8be2\uff0c\u4e0b\u9762\u662f\u8fde\u63a5\u7ba1\u7406\u56fe\uff1a<\/p>\n

\"\"<\/p>\n

coordinator \u8282\u70b9\u4e3a\u6bcf\u4e2a\u4f1a\u8bdd\u90fd\u6709\u4e00\u4e2a\u8fde\u63a5\u6c60\u3002\u6bcf\u4e2a\u67e5\u8be2(\u4f8b\u5982\u56fe\u4e2d\u7684 SELECT * FROM foo)\u4ec5\u9650\u4e8e\u4e3a\u6bcf\u4e2a worker \u7684\u4efb\u52a1\u6253\u5f00\u6700\u591a citus.max_adaptive_executor_pool_size(\u6574\u6570)\u4e2a\u540c\u65f6\u8fde\u63a5\u3002\u8be5\u8bbe\u7f6e\u53ef\u5728\u4f1a\u8bdd\u7ea7\u522b\u8fdb\u884c\u914d\u7f6e\uff0c\u4ee5\u8fdb\u884c\u4f18\u5148\u7ea7\u7ba1\u7406\u3002<\/p>\n

\u5728\u540c\u4e00\u8fde\u63a5\u4e0a\u6309\u987a\u5e8f\u6267\u884c\u77ed\u4efb\u52a1\u6bd4\u4e3a\u5b83\u4eec\u5e76\u884c\u5efa\u7acb\u65b0\u8fde\u63a5\u66f4\u5feb\u3002\u53e6\u4e00\u65b9\u9762\uff0c\u957f\u65f6\u95f4\u8fd0\u884c\u7684\u4efb\u52a1\u53d7\u76ca\u4e8e\u66f4\u76f4\u63a5\u7684\u5e76\u884c\u6027\u3002<\/p>\n

\u4e3a\u4e86\u5e73\u8861\u77ed\u4efb\u52a1\u548c\u957f\u4efb\u52a1\u7684\u9700\u6c42\uff0cCitus \u4f7f\u7528 citus.executor_slow_start_interval(\u6574\u6570)\u3002\u8be5\u8bbe\u7f6e\u6307\u5b9a\u591a\u5206\u7247\u67e5\u8be2\u4e2d\u4efb\u52a1\u7684\u8fde\u63a5\u5c1d\u8bd5\u4e4b\u95f4\u7684\u5ef6\u8fdf\u3002\u5f53\u67e5\u8be2\u9996\u5148\u5bf9\u4efb\u52a1\u8fdb\u884c\u6392\u961f\u65f6\uff0c\u8fd9\u4e9b\u4efb\u52a1\u53ea\u80fd\u83b7\u53d6\u4e00\u4e2a\u8fde\u63a5\u3002\u5728\u6bcf\u4e2a\u6709\u5f85\u5904\u7406\u8fde\u63a5\u7684\u65f6\u95f4\u95f4\u9694\u7ed3\u675f\u65f6\uff0cCitus \u4f1a\u589e\u52a0\u5b83\u5c06\u6253\u5f00\u7684\u540c\u65f6\u8fde\u63a5\u6570\u3002\u901a\u8fc7\u5c06 GUC \u8bbe\u7f6e\u4e3a 0\uff0c\u53ef\u4ee5\u5b8c\u5168\u7981\u7528\u6162\u542f\u52a8\u884c\u4e3a\u3002<\/p>\n

\u5f53\u4efb\u52a1\u5b8c\u6210\u4f7f\u7528\u8fde\u63a5\u65f6\uff0c\u4f1a\u8bdd\u6c60\u5c06\u4fdd\u6301\u8fde\u63a5\u6253\u5f00\u4ee5\u4f9b\u4ee5\u540e\u4f7f\u7528\u3002\u7f13\u5b58\u8fde\u63a5\u907f\u514d\u4e86 coordinator \u548c worker \u4e4b\u95f4\u91cd\u65b0\u5efa\u7acb\u8fde\u63a5\u7684\u5f00\u9500\u3002\u4f46\u662f\uff0c\u6bcf\u4e2a\u6c60\u4e00\u6b21\u6253\u5f00\u7684\u7a7a\u95f2\u8fde\u63a5\u4e0d\u8d85\u8fc7 citus.max_cached_conns_per_worker(\u6574\u6570)\u4e2a\uff0c\u4ee5\u9650\u5236 worker \u4e2d\u7a7a\u95f2\u8fde\u63a5\u8d44\u6e90\u7684\u4f7f\u7528\u3002<\/p>\n

\u6700\u540e\uff0c\u8bbe\u7f6e citus.max_shared_pool_size (integer) \u5145\u5f53\u6545\u969c\u4fdd\u9669\u3002\u5b83\u9650\u5236\u4e86\u6240\u6709\u4efb\u52a1\u4e4b\u95f4\u6bcf\u4e2a worker \u7684\u603b\u8fde\u63a5\u6570\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

Citus \u662f\u4e00\u79cd PostgreSQL \u6269\u5c55\uff0c\u5b83\u5141\u8bb8\u6570\u636e\u5e93\u670d\u52a1\u5668(\u79f0\u4e3a\u8282\u70b9)\u5728\u201c\u65e0\u5171\u4eab(shared not […]<\/p>\n","protected":false},"author":1329,"featured_media":237440,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-237434","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/237434","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/1329"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=237434"}],"version-history":[{"count":3,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/237434\/revisions"}],"predecessor-version":[{"id":237441,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/237434\/revisions\/237441"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/237440"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=237434"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=237434"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=237434"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}