Skip to content

Commit 1c45f0c

Browse files
committed
fix unstable cte_prune again
1 parent 108422d commit 1c45f0c

3 files changed

Lines changed: 8 additions & 5 deletions

File tree

src/test/regress/expected/cte_prune.out

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ insert into t1 values(generate_series(1, 10), generate_series(11, 20), generate_
88
analyze t1;
99
create table t2(v1 int, v2 int, v3 int);
1010
insert into t2 values(generate_series(0, 100), generate_series(100, 200), generate_series(200, 300));
11+
analyze t2;
1112
-- should pruned both seq scan and shared scan
1213
explain verbose with c1 as (select v1, v2, v3 from t1) select c11.v1 from c1 as c11 left join c1 as c22 on c11.v1=c22.v1 where c11.v1 < 5;
1314
QUERY PLAN

src/test/regress/expected/cte_prune_optimizer.out

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ create table t2(v1 int, v2 int, v3 int);
1212
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'v1' as the Apache Cloudberry data distribution key for this table.
1313
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
1414
insert into t2 values(generate_series(0, 100), generate_series(100, 200), generate_series(200, 300));
15+
analyze t2;
1516
-- should pruned both seq scan and shared scan
1617
explain verbose with c1 as (select v1, v2, v3 from t1) select c11.v1 from c1 as c11 left join c1 as c22 on c11.v1=c22.v1 where c11.v1 < 5;
1718
QUERY PLAN
@@ -867,12 +868,12 @@ select c11.v1 from c1 as c11 left join c1 as c22 on c11.v1=c22.v1;
867868
-> Hash Join (cost=0.00..862.00 rows=1 width=4)
868869
Output: t1.v1
869870
Hash Cond: (t1.v1 = t2.v1)
870-
-> Seq Scan on cte_prune.t1 (cost=0.00..431.00 rows=4 width=4)
871-
Output: t1.v1
872-
-> Hash (cost=431.00..431.00 rows=1 width=4)
871+
-> Seq Scan on cte_prune.t2 (cost=0.00..431.00 rows=4 width=4)
873872
Output: t2.v1
874-
-> Seq Scan on cte_prune.t2 (cost=0.00..431.00 rows=1 width=4)
875-
Output: t2.v1
873+
-> Hash (cost=431.00..431.00 rows=1 width=4)
874+
Output: t1.v1
875+
-> Seq Scan on cte_prune.t1 (cost=0.00..431.00 rows=1 width=4)
876+
Output: t1.v1
876877
-> Hash Left Join (cost=0.00..862.00 rows=1 width=4)
877878
Output: share0_ref3.v1
878879
Hash Cond: (share0_ref3.v1 = share0_ref2.v1)

src/test/regress/sql/cte_prune.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ analyze t1;
1010

1111
create table t2(v1 int, v2 int, v3 int);
1212
insert into t2 values(generate_series(0, 100), generate_series(100, 200), generate_series(200, 300));
13+
analyze t2;
1314

1415
-- should pruned both seq scan and shared scan
1516
explain verbose with c1 as (select v1, v2, v3 from t1) select c11.v1 from c1 as c11 left join c1 as c22 on c11.v1=c22.v1 where c11.v1 < 5;

0 commit comments

Comments
 (0)