简体   繁体   English

错误:分布式表的唯一索引必须包含 hash 分布列。 何时从 postgresql 迁移到 postgresql-xl

[英]ERROR: Unique index of distributed table must contain the hash distribution column. when do migration from postgresql to postgresql-xl

I dump sql from postgresql by pg_dump and get below table define:我通过 pg_dump 从 postgresql 转储 sql 并得到下表定义:

CREATE TABLE administrator (
    mtime bigint,
    email text,
    group_id bigint,
    user_account text NOT NULL
);
ALTER TABLE ONLY administrator ADD CONSTRAINT administrator_pkey PRIMARY KEY (user_account);

And I setup postgresql-xl then import the sql file it return:我设置了 postgresql-xl 然后导入它返回的 sql 文件:

ERROR: Unique index of distributed table must contain the hash distribution column.错误:分布式表的唯一索引必须包含 hash 分布列。

The Postgres-XL manual says: Postgres-XL 手册说:

If DISTRIBUTE BY is not specified, columns with UNIQUE constraint will be chosen as the distribution key.如果未指定 DISTRIBUTE BY,则将选择具有 UNIQUE 约束的列作为分布键。 If no such column is specified, distribution column is the first eligible column in the definition.如果未指定此类列,则分布列是定义中的第一个符合条件的列。 If no such column is found, then the table will be distributed by ROUNDROBIN.如果没有找到这样的列,则该表将由 ROUNDROBIN 分发。

If this is ture why my sql file import still return Error?如果这是真的,为什么我的 sql 文件导入仍然返回错误?

Drop Table administrator ;

CREATE TABLE administrator (
    mtime bigint,
    email text,
    group_id bigint,
    user_account text NOT NULL
) DISTRIBUTE BY HASH(user_account);

ALTER TABLE administrator ADD CONSTRAINT administrator_pkey PRIMARY KEY (user_account);

will fix the problem.将解决问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM