您好,欢迎访问一九零五行业门户网

GreenPlum改变表的分布策略

创建一张表,在没有primary key 或者 unique key 的情况下,greenplum默认会把第一个column作为分布键 zwcdb=# create table tab01(id int,name varchar(20));notice: table doesnt have distributed by clause -- using column named id as the greenplum da
创建一张表,在没有primary key 或者 unique key 的情况下,greenplum默认会把第一个column作为分布键
zwcdb=# create table tab01(id int,name varchar(20));notice: table doesn't have 'distributed by' clause -- using column named 'id' as the greenplum database data distribution key for this table.hint: the 'distributed by' clause determines the distribution of data. make sure column(s) chosen are the optimal data distribution key to minimize skew.create tablezwcdb=# zwcdb=# \d+ tab01 table public.tab01 column | type | modifiers | storage | description --------+-----------------------+-----------+----------+------------- id | integer | | plain | name | character varying(20) | | extended | has oids: nodistributed by: (id)
使用以下语句修改分布键zwcdb=# alter table tab01 set distributed by(name);alter tablezwcdb=# \d+ tab01 table public.tab01 column | type | modifiers | storage | description --------+-----------------------+-----------+----------+------------- id | integer | | plain | name | character varying(20) | | extended | has oids: nodistributed by: (name)
在不确定哪个column为分布键的情况下可以使用randomly策略zwcdb=# alter table tab01 set distributed randomly;alter tablezwcdb=# alter table tab01 set with(reorganize=true);alter tablezwcdb=# \d+ tab01 table public.tab01 column | type | modifiers | storage | description --------+-----------------------+-----------+----------+------------- id | integer | | plain | name | character varying(20) | | extended | has oids: nodistributed randomly
其它类似信息

推荐信息