GBase 8a
性能调优
文章

GBase 8a中建表注意事项

发表于2026-07-20 10:56:4210次浏览0个评论

作为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。

评论

登录后才可以发表评论