postgres-xl中的水平分区?

时间:2015-08-13 07:42:21

标签: ubuntu postgres-xl

我在ubuntu中使用postgres-xl。我有一张9排的桌子。我想将该表分为3个部分。知道我是怎么做的吗?

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)

2 个答案:

答案 0 :(得分:2)

不确定如何使用Postgres-XL,但使用enter image description here可以将表格散列分区为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,您可以在以下位置找到文档: pg_shard extension

答案 1 :(得分:1)

您需要在创建表格时指定分配策略:

CREATE TABLE cities (
    name VARCHAR,
    location VARCHAR,
    PRIMARY KEY (location)
)
DISTRIBUTE BY HASH(location);

请注意,在约束方面存在一些缺陷,另请参阅 PostgresXL CREATE TABLE documentation

相关问题