Greenplum 7 新特性整理

0    244    2

Tags:

👉 本文共约11467个字,系统预计阅读时间或需44分钟。

新特性总结

快速拥有GPDB 7和gpcc 7环境

参考:https://www.dbaup.com/zaidockerzhongkuaisutiyangreenplum-7-0-0.html

此docker包括1个master,1个standby master,2个segment,2个mirror实例;还包括gpcc 7.0.0

http://192.168.8.8/28080

gpmon/lhr

重要的新特性

内核

Greenplum 7的内核从9.4.26升级到了12.12,其性能、功能均领先于Greenplum 6

自动启用vacuuum

缺省打开了autovacuum,会自动对系统表进行VACUUM和ANALYZE操作,并对用户表进行ANALYZE操作。

INSERT,UPDATE和DELETE影响的数据量大于下面的计算结果时,会自动对操作的表进行ANALYZE操作:

Automatic Vacuum is now enabled by default for all databases, which automatically performs VACUUM and ANALYZE operations against all catalog tables, as well as runs ANALYZE for all users tables in those databases.

参数含义参考: https://docs.vmware.com/en/VMware-Greenplum/7/greenplum-database/ref_guide-config_params-guc-list.html#autovacuum

示例:

支持仅索引扫描和覆盖索引

增加了对覆盖索引(covering index)的支持。覆盖索引允许用户使用INCLUDE 子句将额外的列添加到索引中,对于执行索引 (index-only)扫描非常有用,特别是对于那些不能被B-tree所索引的数据类型。 Greenplum 查询优化器部分支持索引扫描和覆盖索引。

注意:不能使用GitHub上的开源版本,否则不能使用仅索引扫描和覆盖索引!!!

Index-only scans can answer queries from an index alone without accessing the table’s heap, which significantly improves query performance. In addition, covering indexes allow you to add additional columns to an index using the INCLUDE clause, in order to make the use of index-only scans more effective. See Understanding Index-Only Scans and Covering Indexes for more details.

支持Index only的索引扫描,并支持CREATE INDEX的INCLUDE子句,允许在索引查询时不再回表,从而提升索引查询的性能。

测试环境:

视频:https://www.youtube.com/watch?v=J7_xLoq3E20&t=1383s

引入监控视图可以监控长运行的操作

引入了pg_stat_progress_vacuum/copy/create_index等进度视图。

Greenplum Database can report the progress of ANALYZE, CLUSTER, COPY, CREATE INDEX, REINDEX, and VACUUM commands during command execution. Greenplum can also report the progress of a running base backup (initiated during gprecoverseg -F) command invocation, allowing you to monitor the progress of these possibly long-running operations.

参考:

https://docs.vmware.com/en/VMware-Greenplum/7/greenplum-database/admin_guide-managing-progress_reporting.html

https://greenplum.org/progress-reporting-views-in-greenplum-7/

https://greenplum.org/partition-in-greenplum-7-recursion-and-inheritance/

新增pg_backend_memory_contexts的系统视图

新增了一个名为pg_backend_memory_contexts的系统视图,可以查看后台的内存使用情况。

增加列不再需要重写表

Greenplum Database no longer rewrites the table when a column is added to a table (ALTER TABLE ... ADD COLUMN ...).

ALTER TABLE ... ADD COLUMN ...不再需要重写表:这个功能是PostgreSQL11引入的特性,通过在pg_attribute系统表中增加atthasmissing和attmissingval两个额外字段,所以GP7自然也支持了该功能,可以有效降低加字段所带来的影响。

OperationAO Columnar (AOCO)AO Row (AO)Heap
DROP COLUMNNoNoNo
ALTER COLUMN TYPE [1]No [2]YesYes
ADD COLUMN (w/ non-volative default [3])No [2]NoNo
ADD COLUMN (w/ volative default)No [2]YesYes
ALTER COLUMN SET ENCODINGNo [2]N/AN/A
SET ()[4]YesYesYes
SET ACCESS METHODYesYesYes

[1] If the new type is not binary coercible with the old. Otherwise, no rewrite for all cases.

[2] But write/rewrite single column data.
[3] Including NULL.
[4] If the options differ from the current table. Otherwise, no rewrite for all cases.

参考:https://greenplum.org/alter-table-in-greenplum-7-avoiding-table-rewrite/

分区表

PostgreSQL declarative table partitioning syntaxis now supported. See About Changes to Table Partitioning in Greenplum 7 for more details.

分区表删除的视图:

参考:

https://greenplum.org/20-examples-of-greenplum-partition-commands/

https://greenplum.org/partition-in-greenplum-7-whats-new/

https://greenplum.org/partition-in-greenplum-7-recursion-and-inheritance/

其它

创建分区表

添加新的子分区

删除子分区

将现有分区与另一个表交换

!!!! 这里需要注意的是分区名和表名的区别,使用旧语法创建或者添加子分区的情况下会添加指定的前缀,例如:sales*1_prt_feb_sales中sales_1_prt*是前缀,sales_1_prt_feb_sales是分区名,而表名则是feb_sales 。而在新语法中则是将指定为表名的名称视为表名,没有前缀,例如分区表test。以上例子中sales_1_prt_sales_1_prt_jan_sales和test是分别用新旧两种语法创建的分区表,虽然同为sales的分区表,但是很难将两者联系到一起。因此,建议对于同一分区表,尽量使用相同的新语法或旧语法,以避免名称歧义。

虽然新语法的专业性较低,但一旦熟悉了用法,它们的通用性将能够更轻松地实现更复杂的层次结构。当然如果习惯了旧语法,GPDB7也是兼容的,可以继续使用。
新旧语法比较表

用例旧语法新语法
与父分区一起创建子分区CREATE TABLE … (PARTITION …)CREATE TABLE … PARTITION BY和 CREATE TABLE … PARTITION OF
创建和添加分区ALTER TABLE … ADD PARTITIONCREATE TABLE … PARTITION OF
将现有分区子级与常规表交换ALTER TABLE … EXCHANGE PARTITIONALTER TABLE … DETACH PARTITION和 ATTACH PARTITION
删除分区ALTER TABLE … DROP PARTITIONDROP TABLE
拆分分区ALTER TABLE … SPLIT PARTITIONDETACH 分区和 新分区分开ATTACH

在GPDB7版本中,不再支持多列分区(GPDB6版本也不支持)

但可以创建一个复合类型并将其用作分区键(GPDB6版本不支持)

另外和分区表相关的更新不止是SQL语法上的更新,虽然GPDB7是基于PostgreSQL12.12版本,但是pg_dump命令是和PostgreSQL最新版本pg_dump中的选项一样是可以支持父表和分区表同时转储的

Example 1: Creating a Range Partitioned Table

This example creates a sales table partitioned by range using the sale_date column.

Then adds a new partition to the sales table for the first half of 2023.

Example 2: Classic Range Partitioned Table

For convenience, a single command can be used.

本人提供Oracle(OCP、OCM)、MySQL(OCP)、PostgreSQL(PGCA、PGCE、PGCM)等数据库的培训和考证业务,私聊QQ646634621或微信dbaup66,谢谢!
AiDBA后续精彩内容已被站长无情隐藏,请输入验证码解锁本文!
验证码:
获取验证码: 请先关注本站微信公众号,然后回复“验证码”,获取验证码。在微信里搜索“AiDBA”或者“dbaup6”或者微信扫描右侧二维码都可以关注本站微信公众号。

标签:

Avatar photo

小麦苗

学习或考证,均可联系麦老师,请加微信db_bao或QQ646634621

您可能还喜欢...

发表回复