gpdb icon indicating copy to clipboard operation
gpdb copied to clipboard

enhance aggregate replication safety in planner

Open charliettxx opened this issue 2 years ago • 0 comments

Bug Report

Enhance aggregate replication safety in planner

Greenplum version or build

main

Reproduce Step

CREATE AGGREGATE my_safe_avg (float8)
(
    sfunc = float8_accum,
    stype = float8[],
    finalfunc = float8_avg,
    initcond = '{0,0,0}',
    repsafe = true
);
CREATE TABLE b_reptable (b int) DISTRIBUTED REPLICATED;

EXPLAIN INSERT INTO a_reptable(a) SELECT my_safe_avg(b) FROM b_reptable;
                                        QUERY PLAN                                         
-------------------------------------------------------------------------------------------
 Insert on a_reptable  (cost=1544.50..1544.55 rows=1 width=4)
   ->  Broadcast Motion 1:3  (slice1; segments: 1)  (cost=1544.50..1544.55 rows=1 width=4)
         ->  Subquery Scan on "*SELECT*"  (cost=1544.50..1544.53 rows=1 width=4)
               ->  Aggregate  (cost=1544.50..1544.51 rows=1 width=8)
                     ->  Seq Scan on b_reptable  (cost=0.00..1063.00 rows=96300 width=4)
 Optimizer: Postgres query optimizer
(6 rows)

Goal: we also should eliminate Broadcast Motion in such case above origin related pr: https://github.com/greenplum-db/gpdb/pull/14811

charliettxx avatar Feb 24 '23 02:02 charliettxx