本篇内容介绍了“怎么安装和使用Greenplum开源的列式存储zedstore”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!

安装
从Github上下载源码,与普通PG一样,编译安装即可

[root@localhostpostgres-zedstore]#./configure--enable-debug--with-python--with-perl--with-tcl--with-gssapi--with-pam--with-openssl--with-pam--without-ldap--with-libxml--with-libxslt--enable-dtrace--enable-depend--enable-cassert--with-systemdCFLAGS="-O0-DOPTIMIZER_DEBUG-g3-gdwarf-2"--prefix=/appdb/zedstorecheckingbuildsystemtype...x86_64-pc-linux-gnu...[root@localhostpostgres-zedstore]#make-j4...[root@localhostpostgres-zedstore]#makeinstall...PostgreSQLinstallationcomplete.

Heap vs ZedStore
创建用户,初始化数据库

[zedstore@localhost~]$initdb-Eutf8-D/data/zedstore/testdbThefilesbelongingtothisdatabasesystemwillbeownedbyuser"zedstore".Thisusermustalsoowntheserverprocess.Thedatabaseclusterwillbeinitializedwithlocale"en_US.UTF-8".Thedefaulttextsearchconfigurationwillbesetto"english".Datapagechecksumsaredisabled.creatingdirectory/data/zedstore/testdb...okcreatingsubdirectories...okselectingdynamicsharedmemoryimplementation...posixselectingdefaultmax_connections...100selectingdefaultshared_buffers...128MBselectingdefaulttimezone...PRCcreatingconfigurationfiles...okrunningbootstrapscript...okperformingpost-bootstrapinitialization...oksyncingdatatodisk...okinitdb:warning:enabling"trust"authenticationforlocalconnectionsYoucanchangethisbyeditingpg_hba.conforusingtheoption-A,or--auth-localand--auth-host,thenexttimeyouruninitdb.Success.Youcannowstartthedatabaseserverusing:pg_ctl-D/data/zedstore/testdb-llogfilestart

下面来对比一下head am和zedstore的性能差异
Heap

testdb=#createtablet_heap(idint,c1int,c2varchar(20));CREATETABLEtestdb=#insertintot_heapselectx,x,'c2'||xfromgenerate_series(1,5000000)asx;INSERT05000000testdb=#

执行查询

testdb=#explainanalyzeselectavg(id),sum(c1),max(c2)fromt_heap;QUERYPLAN----------------------------------------------------------------------------------------------------------------------------------------------FinalizeAggregate(cost=69209.94..69209.95rows=1width=72)(actualtime=964.313..964.314rows=1loops=1)->Gather(cost=69209.71..69209.92rows=2width=72)(actualtime=963.978..966.938rows=3loops=1)WorkersPlanned:2WorkersLaunched:2->PartialAggregate(cost=68209.71..68209.72rows=1width=72)(actualtime=929.220..929.220rows=1loops=3)->ParallelSeqScanont_heap(cost=0.00..52584.55rows=2083355width=17)(actualtime=0.094..256.014rows=1666667loops=3)PlanningTime:17.157msExecutionTime:968.461ms(8rows)testdb=#

执行时间为968ms

空间占用

testdb=#selectpg_size_pretty(pg_table_size('t_heap'));pg_size_pretty----------------248MB(1row)

ZedStore

testdb=#createtablet_zedstore(idint,c1int,c2varchar(20))usingzedstore;CREATETABLEtestdb=#insertintot_zedstoreselectx,x,'c2'||xfromgenerate_series(1,5000000)asx;INSERT05000000testdb=#

执行查询

testdb=#explainanalyzeselectavg(id),sum(c1),max(c2)fromt_zedstore;QUERYPLAN-------------------------------------------------------------------------------------------------------------------------------------------------FinalizeAggregate(cost=24917.50..24917.51rows=1width=72)(actualtime=1341.238..1341.239rows=1loops=1)->Gather(cost=24917.27..24917.48rows=2width=72)(actualtime=1341.046..1343.387rows=3loops=1)WorkersPlanned:2WorkersLaunched:2->PartialAggregate(cost=23917.27..23917.28rows=1width=72)(actualtime=1328.432..1328.432rows=1loops=3)->ParallelSeqScanont_zedstore(cost=0.00..18968.87rows=659787width=17)(actualtime=0.702..837.075rows=1666667loops=3)PlanningTime:0.643msExecutionTime:1343.612ms(8rows)testdb=#

使用zedstore的时间是1343ms,比起heap方式要慢接近40%。

空间占用

testdb=#selectpg_size_pretty(pg_table_size('t_zedstore'));pg_size_pretty----------------97MB(1row)testdb=#

不过使用zedstore,空间占用倒是只有原来的40%左右。

“怎么安装和使用Greenplum开源的列式存储zedstore”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注亿速云网站,小编将为大家输出更多高质量的实用文章!