greenplum 列模式与行模式对比

--建表
CREATE TABLE ds_chn_prd_serv_col_201108
(
...
)
WITH (APPENDONLY=true, COMPRESSTYPE=quicklz, ORIENTATION=COLUMN,
  OIDS=FALSE
)
DISTRIBUTED BY (serv_id);

CREATE TABLE ds_chn_prd_serv_row_201108
(
...
)
WITH (APPENDONLY=true, COMPRESSTYPE=quicklz, ORIENTATION=ROW,
  OIDS=FALSE
)
DISTRIBUTED BY (serv_id);

--数据准备

insert into ds_chn_prd_serv_col_201108 select * from ds_chn_prd_serv_201108;
insert into ds_chn_prd_serv_row_201108 select * from ds_chn_prd_serv_201108;

--记录条数 20363699

--列模式测试
--3549   3892 3785
select * from ds_chn_prd_serv_col_201108  where acc_nbr in ('13388948142','13399826222');
--4248 4793 3979
select * from ds_chn_prd_serv_col_201108  where serv_id in (20001106,20001162);

--574  582 573
select user_name from ds_chn_prd_serv_col_201108  where acc_nbr in ('13388948142','13399826222');
--471 735 745
select user_name from ds_chn_prd_serv_col_201108  where serv_id in (20001106,20001162);

--702 594
select count(*),max(serv_id) from ds_chn_prd_serv_col_201108 ;


----行模式测试
--3869 3306 3120
select * from ds_chn_prd_serv_row_201108  where acc_nbr in ('13388948142','13399826222');
--3639 3440 4066
select * from ds_chn_prd_serv_row_201108  where serv_id in (20001106,20001162);

--3210 3205 3298
select user_name from ds_chn_prd_serv_row_201108  where acc_nbr in ('13388948142','13399826222');
--4046 3582 2895
select user_name from ds_chn_prd_serv_row_201108  where serv_id in (20001106,20001162);

--4120 3335
select count(*),max(serv_id) from ds_chn_prd_serv_row_201108 ;

--总结
主机配置:....
总记录数 20363699
       row   col
全字段查询     3.7   3.7
部分字段查询(选取一个字段) 3.2   0.55
汇总查询     3.6   0.55

--结论
 列模式适合宽表设计(多字段表),在查询时只查询部分字段的情况,效率高于行模式
 
 
-表清理
drop table ds_chn_prd_serv_row_201108;
drop table ds_chn_prd_serv_col_201108;

 

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值