博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
关于greenplum中的appendonly表
阅读量:4032 次
发布时间:2019-05-24

本文共 2163 字,大约阅读时间需要 7 分钟。

    在greenplum里面有一种appendonly表,只能insert,不能update、delete的一种表,对于压缩表跟列存储来说,前提是必须是appendonly的表。下面介绍appendonly表的一些特性。

1.首先建一张appendonly的表:

aligputf8=# create table cxf_test1 with(appendonly=true,compresslevel=5) as select generate_series(0,1000) a,’helloworld’::varchar(50) b distributed by (a);SELECT 1001

2.查一下表的oid:

aligputf8=# select oid from pg_class where relname=’cxf_test1′;  oid  ——– 383660(1 row) aligputf8=# select oid,oid::regclass from pg_class where relname=’cxf_test1′ or relname like ‘%383660%’;  oid   |              oid              ——–+——————————– 383665 | pg_aoseg.pg_aoseg_383660 383666 | pg_aoseg.pg_aoseg_383660_index 383660 | cxf_test1(3 rows)

在gp3.3.*的版本里面,aoseg表的信息是记录在pg_class中的relaosegrelid 字段,是以这个为准的

aligputf8=# select relaosegrelid from pg_class where relname=’cxf_test1′; relaosegrelid—————        383665(1 row)

在gp4.*的版本里面,pg_class的relaosegrelid 字段已经取消掉了,这个信息保留在了pg_appendonly表中的segrelid字段中了。

 

3.aoseg表的字段信息

aligputf8=# \d pg_aoseg.pg_aoseg_383660    “pg_aoseg.pg_aoseg_383660″     Column      |       Type      —————–+—————— segno           | integer eof             | double precision tupcount        | double precision varblockcount   | double precision eofuncompressed | double precision

这个表每个字段的意思gp的文档里面没有,大概觉得每个字段信息应该是:

Segno: 这个字段还不是很清楚,第一次建表的时候是0,truncate之后就变成1了,再truncate还是1。

eof     :压缩后文件大小

tupcount:表的函数

varblockcount:表占用的块数量

eofuncompressed:未压缩表的大小

 

aligputf8=# select * from gp_dist_random(’pg_aoseg.pg_aoseg_383660′); segno | eof | tupcount | varblockcount | eofuncompressed——-+—–+———-+—————+—————–     0 | 732 |      161 |             1 |            4204     0 | 728 |      161 |             1 |            4204     0 | 720 |      159 |             1 |            4152     0 | 808 |      181 |             1 |            4724     0 | 796 |      178 |             1 |            4644     0 | 728 |      161 |             1 |            4204(6 rows)

通过gp_dist_random这个函数,我们可以知道gp底层每个数据节点数据量,数据文件大小的情况,这样子我们就能够分析表的数据分布情况,算出倾斜率等。

基于appendonly表,我开发了两个gp的函数:

get_table_count是获取append only表的行数的,appendonly表有一个字段是保存这些信息的。这个函数获取表的函数很快,支持分区表. 

aligputf8=# select * from get_table_count(’rtdc.cxf_test1′); get_table_count—————–  1001(1 row)

转载地址:http://aeebi.baihongyu.com/

你可能感兴趣的文章
android中shader的使用
查看>>
java LinkedList与ArrayList迭代器遍历和for遍历对比
查看>>
Android DataBinding使用2-Recycleview
查看>>
drat中构造方法
查看>>
JavaScript的一些基础-数据类型
查看>>
JavaScript基础知识(2)
查看>>
转载一个webview开车指南以及实际项目中的使用
查看>>
关于activity保存页面状态的两个方法
查看>>
android中对于非属性动画的整理
查看>>
一个简单的TabLayout的使用
查看>>
关于let{a}=B出现的解构赋值
查看>>
ReactNative使用Redux例子
查看>>
Promise的基本使用
查看>>
android给文字加边框(修改不能居中的问题)
查看>>
coursesa课程 Python 3 programming course_2_assessment_1
查看>>
coursesa课程 Python 3 programming 统计文件有多少单词
查看>>
coursesa课程 Python 3 programming 输出每一行句子的第三个单词
查看>>
coursesa课程 Python 3 programming Dictionary methods 字典的方法
查看>>
Returning a value from a function
查看>>
coursesa课程 Python 3 programming Functions can call other functions 函数调用另一个函数
查看>>