《Greenplum企业应用实战》一3.4 数据压缩

    xiaoxiao2023-06-06  159

    本节书摘来自华章出版社《Greenplum企业应用实战》一书中的第3章,第3.4节,作者 何勇 陈晓峰,更多章节内容可以访问云栖社区“华章计算机”公众号查看

    3.4 数据压缩

    3.4.1 数据加载速度影响

    基于table_distribute_4表创建一个普通的表。从Greenplum Performance Monitor页面可看到,在dell3和dell4上有大量磁盘写操作,如图3-10所示。建表语句如下:

    testDB=# create table test_compress_1 as select * from test_distribute_1 distributed by(flag); SELECT 5000000

    基于table_distribute_4表创建一个压缩表。由于数据压缩比很大,从Greenplum Performance Monitor页面可看到,在dell3和dell4上基本没有磁盘写操作,只有读操作,如图3-11所示。建表语句如下:

    testDB=# create table test_compress_2 with(appendonly=true,compresslevel=5) as select * from test_distribute_1 distributed by(flag); SELECT 5000000

    3.4.2 数据查询速度影响

    (1)普通表的数据查询

    testDB=# select gp_segment_id,count(*),max(length(value)) from test_compress_1 group by 1; gp_segment_id | count | max ---------------+---------+------ 3 | 2498434 | 1024 2 | 2501566 | 1024 (2 rows) Time: 65589.914 ms

    磁盘消耗较大,如图3-12所示。

    (2)压缩表的数据查询

    testDB=# select gp_segment_id,count(*),max(length(value)) from test_compress_2 group by 1; gp_segment_id | count | max ---------------+---------+------ 3 | 2498434 | 1024 2 | 2501566 | 1024 (2 rows) Time: 23004.626 ms

    由于数据经过压缩,占用存储空间很小,从Greenplum Performance Monitor页面可看到,几乎没有磁盘读操作,如图3-13所示。

    相关资源:Hadoop实战(陆嘉恒)译
    最新回复(0)