GP6和GP7中的分区表视图变化

0    180    1

Tags:

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

About the Greenplum 6 and 7 Partitioning Catalogs

以下在 Greenplum 6 中可用的与分区相关的目录表、视图和函数在 Greenplum 7 中已被移除:

Greenplum 7 新增了以下目录表和函数:

pg_partitions

The Greenplum 6 pg_partitions view displays all leaf partitions in the current database.

Column NameGreenplum 6 DescriptionGreenplum 7 Equivalent
schemanameThe name of the schema in which the root partitioned table resides.Use pg_partition_root() to obtain the root object identifier, and then query pg_namespace.
tablenameThe name of the root partitioned table.Use pg_partition_root() to obtain the root object identifier, and then query pg_class.
partitionschemanameThe namespace of the leaf partition.pg_namespace
partitiontablenameThe table name of the leaf partition (the table name you use to access the partition directly).pg_class
partitionnameThe partition name of the leaf partition (the name you use to refer to the partition in an ALTER TABLE command).N/A
parentpartitiontablenameThe table name of the parent table of this partition.Get the parent object identifier via pg_inherits and then query pg_class.
parentpartitionnameThe partition name of the parent table of this partition.N/A
partitiontypeThe type of partition (range or list).Get the parent object identifier via pg_inherits and then query pg_partitioned_table.
partitionlevelThe level of this partition in the partition hierarchy.Get the level from pg_partition_tree() using the root object identifier. Note that the level differs in Greenplum 6 and 7. In Greenplum 6, the level of the immediate child of a partitioned table is 0. In Greenplum 7, the level of the partitioned table itself is 0, and the level of its immediate child is 1.
partitionrankFor range partitions, the rank of the partition compared to other partitions at the same level.N/A
partitionpositionThe rule order position of this partition.N/A
partitionlistvaluesFor list partitions, the list value(s) associated with this partition.Get the partition boundary via pg_get_expr() and then filter the text.
partitionrangestartFor range partitions, the start value of this partition.Get the partition boundary via pg_get_expr() and then filter the text.
partitionstartinclusiveWhether or not the start value is included in this partition. true if the start value is included.always inclusive
partitionrangeendFor range partitions, the end value of this partition.Get the partition boundary via pg_get_expr() and then filter the text.
partitionendinclusiveWhether or not the end value is included in this partition. true if the end value is included.always exclusive
partitioneveryclauseThe EVERY clause (interval) of this partition.N/A
partitionisdefaultWhether or not this is a default partition. true if this is the default, otherwise false.Get the partition boundary via pg_get_expr() and check if it is DEFAULT. Alternatively, use pg_partitioned_table.partdefid.
partitionboundaryThe entire partition specification for this partition.pg_get_expr(), but note that it is returned in modern syntax.
parenttablespaceThe tablespace of the parent table of this partition.Get the parent object identifier via pg_inherits and then query pg_tablespace.
partitiontablespaceThe tablespace of this partition.pg_tablespace

Examples Retrieving Similar Information in Greenplum 7

partitionname / parentpartitionname

The partitionname and parentpartitionname columns provide the Greenplum 6 "partition name" in constrast to the actual table name. Because Greenplum 7 no longer stores the partition name in the catalog (previously in pg_partition_rule), it cannot retrieve that information now. Use the table names directly to refer to the partitions. However, if you really need the partition name, you can achieve that via some text massaging:

This query is valid only if the table name is implicitly generated by Greenplum from the partition name and is in the form of <parent_tablename>_prt_<level>_<partition_name>. This query will not work for a partitioned table created with modern syntax (where you always specify the table name when adding a partition) or for a partitioned table created with classic syntax where you explicitly specify the table name in a WITH clause for the partition.

partitionposition / partitionrank

The partitionposition and partitionrank columns in the Greenplum 6 pg_partitions view are based on the "order" number for each partition in the pg_partition_rule catalog, but that catalog is removed in Greenplum 7. However, if you are simply interested in retrieving the sorted order for range partitions, you can order the range value. For example, if the Greenplum 6 query below provides the highest rank partition:

A similar query in Greenplum 7 follows:

Assuming that the partitioning method for the partitioned table is RANGE, the above query calculates the ranks for each child partition, and prints the range START value (which is always inclusive) with the highest rank.

You cannot retrieve the order number for list partitions with this query, however, because the order is based on the time the partition is added, and Greenplum 7 does not store that information. A query for list partitions must not be dependent on order information.

partitioneveryclause

Because Greenplum 7 does not store the use of the EVERY clause in the catalog, it can not discern if a partition was created with the clause. The main use of this column is to reconstruct a partition definition clause using the classic-syntax for display or pg_dump purposes. No mapping is provided at this time.

partitionstartinclusive / partitionendinclusive

Greenplum 7 supports the classic syntax INCLUSIVE and EXCLUSIVE clauses through the adjustment of START and END values. It dos not record whether a range START or END is inclusive or not, because the START is always inclusive and the END is always exclusive. So the partitionstartinclusive and partitionendinclusive columns are simply redundant.

partitionboundary

You can retrieve the partition boundary definition in Greenplum 7 via the pg_get_expr() function:

Composing a Similar View in Greenplum 7

An approximate pg_partitions view follows. This view, given all limitations addressed above, prints the information that is possible to retrieve in Greenplum 7.

Caution

This example is for illustrative purposes only, not for practical use.

pg_partition_columns

The Greenplum 6 pg_partition_columns view displays the partition key columns of a partitioned table.

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

标签:

Avatar photo

小麦苗

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

您可能还喜欢...

发表回复