Greenplum 分区表介绍
来源:互联网 发布:网络言情小说作家 编辑:程序博客网 时间:2024/05/21 15:03
Greenplum 分区表
Greenplum分区表的原理和postgresql的原理相同,都是把一张大表进行按照适合的维度进行分割,通过表的继承,规则,约束实现的。
在Greenplum中,一个表是否分区表保存在pg_partition中.
GP在建表的时候会有一个DISTRIBUTED BY选项,这个是表进行物理拆分,理解一下分区和分布:
1.分区,按照字段逻辑进行逻辑划分的区域,比如,时间按天,按月等等
2.分布,按照字段进行物理分区,会分散到每个segment
分布式为了并行查询效率,充分利用每个segment节点的资源,分区是为了减少查询时的数据扫描,对大表维护更加方便。
支持的分区类型:
范围分区
列表分区
组合分区
实例:
create table test_partition (id int,sex varchar(1))
distributed by (id)
partition by list(sex)
(partition man values ('M'),
partition woman values ('W'),
default partition other);
NOTICE: CREATE TABLE will create partition "test_partition_1_prt_man" for table "test_partition"
NOTICE: CREATE TABLE will create partition "test_partition_1_prt_woman" for table "test_partition"
NOTICE: CREATE TABLE will create partition "test_partition_1_prt_other" for table "test_partition"
insert into test_partition values(1,'M');
insert into test_partition values(2,'M');
insert into test_partition values(3,'M');
insert into test_partition values(4,'W');
insert into test_partition values(5,'W');
insert into test_partition values(6,'W');
insert into test_partition values(7,'W');
insert into test_partition values(8,'O');
insert into test_partition values(9,'O');
SELECT gp_segment_id,count(*) from test_partition group by 1;
gp_segment_id | count
---------------+-------
8 | 1
62 | 1
47 | 1
57 | 1
52 | 1
13 | 1
3 | 1
42 | 1
18 | 1
可见分布在不同的segment
查看分区:
gpadmin=# select * from test_partition_1_prt_man;
id | sex
----+-----
1 | M
2 | M
3 | M
(3 rows)
gpadmin=# select * from test_partition_1_prt_woman;
id | sex
----+-----
7 | W
4 | W
5 | W
6 | W
(4 rows)
gpadmin=# select * from test_partition_1_prt_other;
id | sex
----+-----
8 | O
9 | O
(2 rows)
参考:
http://gpdb.docs.pivotal.io/500/admin_guide/ddl/ddl-partition.html#topic_tvx_nsz_bt
可见分区表存储了相关分区的记录
阅读全文
0 0
- GreenPlum分区表介绍
- Greenplum 分区表介绍
- GreenPlum分区表
- Greenplum介绍
- 分区表介绍
- greenplum分区表查看所占空间大小
- greenplum分区表查看所占空间大小
- Greenplum入门介绍
- Greenplum介绍 - Partitioned Table
- GREENPLUM系列介绍之安装
- GREENPLUM系列介绍之安装
- greenplum 表管理及查看分区表占空间大小
- Greenplum中多级分区表详解--3层分区
- Oracle 分区表介绍
- Oracle分区表介绍
- 分区表简单介绍
- Oracle 分区表介绍
- Greenplum
- 用SVD压缩深度模型(DNN,CNN)的全连接层(fully-connected layer)
- 产品流程
- 【开始】总要写点啥
- 添加图片水印
- nginx 静态资源访问配置
- Greenplum 分区表介绍
- HDU 1385 Minimum Transport Cost(floyd)(记录路径)
- Windows 下单机最大TCP连接数
- Java软件工程师 (职业简介)
- 利用JDB附加调试JAVA程序
- stm32 死区 刹车 pwm
- CNN的压缩和加速
- js常用正则表达式
- 解决ubuntu16.04中ttyUSB设备节点不固定问题