GBase 8a中建表注意事项
作为MPP 数据库,分布列的选择尤其重要,对性能影响在某些情况下能达到1~2个量级。 选择合适的建表语句,对业务来说至关重要。
一、建表范例
create table t_hash_bigtable(id int,name varchar(10)) compress('STDZ',0) distributed by ('id'); -- 分布表,分布列是id。
create table t_hash_smalltable(id int,name varchar(10)) compress('STDZ',0) replicated; -- 复制表
切换库:use test ;
看表列: desc t_hash_bigtable;
看表创建语句: show create table test.t_hash_bigtable ; show create table test.t_hash_smalltable;
修改分布列:需要转储,如修改上面 t_hash_bigtable 。
alter table t_hash_bigtable rename to t_hash_bigtable_old;
create table t_hash_bigtable distributed by ('name') compress ('STDZ',0) as
select * from t_hash_bigtable_old limit 10;
-- 没问题后 drop table t_hash_bigtable_old;
二、建表说明
大表创建为分布表,分布列选择用于join的,重复值较低的列;
小表创建为复制表,一般数据量低于10万;
表压缩,使用 STDZ,0 。默认不指定压缩走55压缩,大概1T数据压缩后200GB,STDZ压缩后做的,大概120GB。
评论
热门帖子
- 12025-12-01浏览数:182759
- 22023-05-09浏览数:25049
- 42023-09-25浏览数:18521
- 52020-05-11浏览数:17526