GPDB-内核特性-GP7不再支持动态分区裁剪

简介: GPDB-内核特性-GP7不再支持动态分区裁剪

GPDB-内核特性-GP7不再支持动态分区裁剪


GreenPlum支持分区表的功能,并通过分区裁剪来减少读取的数据量。分区裁剪分为静态分区裁剪和动态分区裁剪。静态分区裁剪:执行计划在生成时,就通过条件值过滤出需要的子分区,执行时仅扫描裁剪后的分区即可;动态分区裁剪:发生在SQL执行阶段,需要根据维度表的数据动态分析出需要哪些分区。


GP6ORCA支持动态分区功能:


    set optimizer=on;
    explain select * from sales;
                                                  QUERY PLAN                                              
    ------------------------------------------------------------------------------------------------------
     Gather Motion 1:1  (slice1; segments: 1)  (cost=0.00..431.00 rows=1 width=16)
       ->  Sequence  (cost=0.00..431.00 rows=1 width=16)
             ->  Partition Selector for sales (dynamic scan id: 1)  (cost=10.00..100.00 rows=100 width=4)
                   Partitions selected: 366 (out of 366)
             ->  Dynamic Seq Scan on sales (dynamic scan id: 1)  (cost=0.00..431.00 rows=1 width=16)
     Optimizer: Pivotal Optimizer (GPORCA)
    (6 rows)

    引入SequencePartitionSelectorDynamicSeqScan等算子完成动态分区裁剪。PartitionSelector根据数据分析出需要哪些分区,DynamicSeqScan扫描对应分区,Sequence负责处理所有DynamicSeqScan算子。

    然而,GP7中进行测试时,发现执行计划不一样了:

      set optimizer=on;
      explain select * from sales;
                                             QUERY PLAN                                        
      -----------------------------------------------------------------------------------------
       Gather Motion 1:1  (slice1; segments: 1)  (cost=0.00..812886.00 rows=22179600 width=24)
         ->  Append  (cost=0.00..369294.00 rows=22179600 width=24)
               ->  Seq Scan on sales_1_prt_1  (cost=0.00..706.00 rows=60600 width=24)
               ->  Seq Scan on sales_1_prt_2  (cost=0.00..706.00 rows=60600 width=24)
               ->  Seq Scan on sales_1_prt_3  (cost=0.00..706.00 rows=60600 width=24)
                ................
                ................
               ->  Seq Scan on sales_1_prt_364  (cost=0.00..706.00 rows=60600 width=24)
               ->  Seq Scan on sales_1_prt_365  (cost=0.00..706.00 rows=60600 width=24)
               ->  Seq Scan on sales_1_prt_366  (cost=0.00..706.00 rows=60600 width=24)
       Optimizer: Postgres query optimizer
      (369 rows)

      发生了什么?经过分析查看GreenPlumissues,发现GP7竟然不支持动态分区了:

      https://github.com/greenplum-db/gpdb/issues/11363

      Partition table support in Orca was disabled for the master branch and we currently fall back to planner on all queries on partition tables. We are actively working to add this functionality back (eg: #11336 re-introduces support for static partition elimination).

      Master分支中,目前是GP7Orca禁用了分区表,执行计划又回到要查询所有分区表。我们正在积极做这个事,#11336重新引入支持静态分区裁剪功能:

      https://github.com/greenplum-db/gpdb/pull/11336

      Does this mean there will be no Dynamic scan node added to the plan?

      @JunfengYang Yes, our current plan is to not use DynamicXXXScan nodes anymore, and use the Append node (just as in Planner) with enumerated Scan node children.

      当前版本计划,不再使用DynamicXXXScan节点了,而是使用带有枚举Scan子节点的Append节点完成。

      那么,GP7中如何实现动态分区裁剪的效果呢?

        Gather Motion
          ->Nest Loop
            ->Append
              ->SeqScan on tpart1
              ->SeqScan on tpart2
              ->...
              ->SeqScan on tpartn
            ->Material
              ->Partition Selector
                ->SeqScan on t1

        比如一个nest loop join,通过顺序扫描表t1,将他的值都扫描出来,然后通过PartitionSelector算子判断这些值落在哪个分区表中,并将所有值通过Material算子物化;Append算子根据PartitionSelector算子计算的分区,顺序扫描这些的到的分区得到值,与Material算子物化值进行join。

        目录
        相关文章
        |
        Java Linux 索引
        ElasticSearch常见的报错及解决
        ElasticSearch常见的报错及解决
        802 0
        |
        存储 Kubernetes NoSQL
        【K8S系列】深入解析K8S存储
        【K8S系列】深入解析K8S存储
        1100 0
        |
        存储 JSON API
        【Elasticsearch专栏 16】深入探索:Elasticsearch的Master选举机制及其影响因素分析
        Elasticsearch,开源搜索和分析引擎,以其分布式特性受开发者喜爱。本文聚焦其Master选举过程,关键在于保障集群稳健和高可用。Master负责集群操作,数据节点存储数据。选举在Master不可用时发生,基于Zen Discovery模块,遵循多数派协议。选举过程包括启动发现、选举触发、节点投票和状态同步。相关命令和配置有助于管理选举和集群状态。理解和优化选举机制能提升Elasticsearch集群的性能和稳定性。
        313 1
        |
        SQL 存储 算法
        PostgreSQL 执行计划,成本公式解说,代价因子校准,自动跟踪SQL执行计划(二)|学习笔记
        快速学习PostgreSQL 执行计划,成本公式解说,代价因子校准,自动跟踪SQL执行计划(二)
        PostgreSQL 执行计划,成本公式解说,代价因子校准,自动跟踪SQL执行计划(二)|学习笔记
        |
        消息中间件 前端开发 小程序
        DDD实战之五:战略设计之上下文映射和系统分层架构(下)
        DDD实战之五:战略设计之上下文映射和系统分层架构(下)
        DDD实战之五:战略设计之上下文映射和系统分层架构(下)
        |
        缓存 JSON 运维
        深入探讨API调用性能优化与错误处理
        随着互联网技术的不断发展,API(应用程序接口)已经成为软件系统中重要的组成部分。而优化API调用的性能以及处理错误和异常情况则是保障系统稳定性和可靠性的关键。本文将从以下几个方面来探讨如何进行性能优化和错误处理。
        |
        关系型数据库 索引 Perl
        理解 postgresql.conf 的work_mem 参数配置
        主要是通过具体的实验来理解 work_mem
        7303 0
        |
        SQL 存储 分布式计算
        手把手教学hive on spark,还不会的小伙伴快上车了
        Hive3.1.2源码编译+Spark3.0.0+Hadoop3.1.3
        853 0
        ES选举:Elasticsearch中Master选举完全解读
        ES选举:Elasticsearch中Master选举完全解读
        ES选举:Elasticsearch中Master选举完全解读
        |
        Kubernetes 网络协议 容器
        Kubernetes开源LoadBalancer—Metallb(BGP)
        Kubernetes开源LoadBalancer—Metallb(BGP)
        Kubernetes开源LoadBalancer—Metallb(BGP)