我在ubuntu中使用postgres-xl。我有一张9行的桌子。我想把那张桌子分成三部分。知道我是怎么做到的吗?
postgres=# SELECT * FROM cities;
name | location
------+----------
a | 1
a | 2
a | 4
a | 3
a | 4
a | 5
a | 6
a | 11
a | 14
(9 rows)发布于 2015-08-18 23:24:23
不确定如何使用Postgres-XL,但使用pg_shard extension,您可以将表散列分区为3个(或更多)部分:
CREATE TABLE cities (name text, location int);
SELECT master_create_distributed_table('cities', 'location');
SELECT master_create_worker_shards('cities', 3, 2);要开始使用pg_shard,您可以在以下位置找到文档:https://github.com/citusdata/pg_shard
发布于 2016-09-08 18:00:29
您需要在创建表时指定您的分发策略:
CREATE TABLE cities (
name VARCHAR,
location VARCHAR,
PRIMARY KEY (location)
)
DISTRIBUTE BY HASH(location);请注意,在约束方面有几个陷阱,另请参阅PostgresXL CREATE TABLE documentation。
https://stackoverflow.com/questions/31982324
复制相似问题