Skip to content

Commit 860d050

Browse files
committed
Set constraint_exclusion to CONSTRAINT_EXCLUSION_ON
1 parent 4c5df54 commit 860d050

File tree

7 files changed

+96
-117
lines changed

7 files changed

+96
-117
lines changed

src/backend/utils/misc/guc_tables.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4744,7 +4744,7 @@ struct config_enum ConfigureNamesEnum[] =
47444744
GUC_EXPLAIN
47454745
},
47464746
&constraint_exclusion,
4747-
CONSTRAINT_EXCLUSION_PARTITION, constraint_exclusion_options,
4747+
CONSTRAINT_EXCLUSION_ON, constraint_exclusion_options,
47484748
NULL, NULL, NULL
47494749
},
47504750

src/test/regress/expected/bfv_aggregate.out

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1590,16 +1590,18 @@ create temp table mpp14125 as select repeat('a', a) a, a % 10 b from generate_se
15901590
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column(s) named 'a' as the Apache Cloudberry data distribution key for this table.
15911591
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
15921592
explain select string_agg(a, '') from mpp14125 group by b;
1593-
QUERY PLAN
1594-
------------------------------------------------------------------------------------------------
1595-
Gather Motion 3:1 (slice1; segments: 3) (cost=6.50..6.83 rows=10 width=36)
1596-
-> HashAggregate (cost=6.50..6.62 rows=4 width=36)
1593+
QUERY PLAN
1594+
------------------------------------------------------------------------------------------------------
1595+
Gather Motion 3:1 (slice1; segments: 3) (cost=322.00..339.50 rows=1000 width=36)
1596+
-> Finalize HashAggregate (cost=322.00..326.17 rows=333 width=36)
15971597
Group Key: b
1598-
-> Redistribute Motion 3:3 (slice2; segments: 3) (cost=0.00..6.00 rows=34 width=55)
1598+
-> Redistribute Motion 3:3 (slice2; segments: 3) (cost=282.00..314.50 rows=1000 width=36)
15991599
Hash Key: b
1600-
-> Seq Scan on mpp14125 (cost=0.00..4.00 rows=34 width=55)
1600+
-> Partial HashAggregate (cost=282.00..294.50 rows=1000 width=36)
1601+
Group Key: b
1602+
-> Seq Scan on mpp14125 (cost=0.00..199.33 rows=16533 width=36)
16011603
Optimizer: Postgres query optimizer
1602-
(7 rows)
1604+
(9 rows)
16031605

16041606
-- end MPP-14125
16051607
-- Test that integer AVG() aggregate is accurate with large values. We used to
@@ -1775,14 +1777,12 @@ explain (costs off)
17751777
select 1, sum(col1) from group_by_const group by 1;
17761778
QUERY PLAN
17771779
------------------------------------------------
1778-
Finalize GroupAggregate
1779-
Group Key: 1
1780+
Finalize Aggregate
17801781
-> Gather Motion 3:1 (slice1; segments: 3)
1781-
-> Partial GroupAggregate
1782-
Group Key: 1
1782+
-> Partial Aggregate
17831783
-> Seq Scan on group_by_const
17841784
Optimizer: Postgres query optimizer
1785-
(7 rows)
1785+
(5 rows)
17861786

17871787
select 1, sum(col1) from group_by_const group by 1;
17881788
?column? | sum
@@ -1794,16 +1794,13 @@ select 1, sum(col1) from group_by_const group by 1;
17941794
-- that you get a one-phase aggregate plan.
17951795
explain (costs off)
17961796
select 1, median(col1) from group_by_const group by 1;
1797-
QUERY PLAN
1798-
------------------------------------------------------------
1799-
Gather Motion 3:1 (slice1; segments: 3)
1800-
-> GroupAggregate
1801-
Group Key: 1
1802-
-> Redistribute Motion 3:3 (slice2; segments: 3)
1803-
Hash Key: 1
1804-
-> Seq Scan on group_by_const
1797+
QUERY PLAN
1798+
------------------------------------------------
1799+
GroupAggregate
1800+
-> Gather Motion 3:1 (slice1; segments: 3)
1801+
-> Seq Scan on group_by_const
18051802
Optimizer: Postgres query optimizer
1806-
(7 rows)
1803+
(4 rows)
18071804

18081805
select 1, median(col1) from group_by_const group by 1;
18091806
?column? | median
@@ -1869,7 +1866,7 @@ explain select count(distinct b) from t1_replicated group by a;
18691866
-> GroupAggregate (cost=5519.77..5984.27 rows=1000 width=12)
18701867
Group Key: a
18711868
-> Sort (cost=5519.77..5671.27 rows=60600 width=8)
1872-
Sort Key: a
1869+
Sort Key: a, b
18731870
-> Seq Scan on t1_replicated (cost=0.00..706.00 rows=60600 width=8)
18741871
Optimizer: Postgres query optimizer
18751872
(7 rows)

src/test/regress/expected/join.out

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2856,9 +2856,11 @@ select count(*) from
28562856
-> Gather Motion 3:1 (slice2; segments: 3)
28572857
Merge Key: y.unique2
28582858
-> Subquery Scan on y
2859-
-> Index Scan using tenk1_unique2 on tenk1 y_1
2859+
-> Sort
2860+
Sort Key: y_1.unique2
2861+
-> Seq Scan on tenk1 y_1
28602862
Optimizer: Postgres query optimizer
2861-
(16 rows)
2863+
(18 rows)
28622864

28632865
select count(*) from
28642866
(select * from tenk1 x order by x.thousand, x.twothousand, x.fivethous) x
@@ -6483,15 +6485,12 @@ explain (costs off)
64836485
select p.* from
64846486
parent p left join child c on (p.k = c.k)
64856487
where p.k = 1 and p.k = 2;
6486-
QUERY PLAN
6487-
------------------------------------------------------
6488-
Gather Motion 1:1 (slice1; segments: 1)
6489-
-> Result
6490-
One-Time Filter: false
6491-
-> Index Scan using parent_pkey on parent p
6492-
Index Cond: (k = 1)
6488+
QUERY PLAN
6489+
-------------------------------------
6490+
Result
6491+
One-Time Filter: false
64936492
Optimizer: Postgres query optimizer
6494-
(6 rows)
6493+
(3 rows)
64956494

64966495
select p.* from
64976496
(parent p left join child c on (p.k = c.k)) join parent x on p.k = x.k

src/test/regress/expected/join_gp.out

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -341,21 +341,12 @@ create table bar (c int, d int) distributed randomly;
341341
insert into foo select generate_series(1,10);
342342
insert into bar select generate_series(1,10);
343343
explain select a from foo where a<1 and a>1 and not exists (select c from bar where c=a);
344-
QUERY PLAN
345-
--------------------------------------------------------------------------------------------------------
346-
Gather Motion 3:1 (slice1; segments: 3) (cost=473.83..1458.05 rows=430 width=4)
347-
-> Hash Right Anti Join (cost=473.83..1452.31 rows=144 width=4)
348-
Hash Cond: (bar.c = foo.a)
349-
-> Redistribute Motion 3:3 (slice2; segments: 3) (cost=0.00..895.00 rows=28700 width=4)
350-
Hash Key: bar.c
351-
-> Seq Scan on bar (cost=0.00..321.00 rows=28700 width=4)
352-
-> Hash (cost=470.24..470.24 rows=287 width=4)
353-
-> Redistribute Motion 3:3 (slice3; segments: 3) (cost=0.00..470.24 rows=287 width=4)
354-
Hash Key: foo.a
355-
-> Seq Scan on foo (cost=0.00..464.50 rows=287 width=4)
356-
Filter: ((a < 1) AND (a > 1))
344+
QUERY PLAN
345+
------------------------------------------
346+
Result (cost=0.00..0.00 rows=0 width=4)
347+
One-Time Filter: false
357348
Optimizer: Postgres query optimizer
358-
(12 rows)
349+
(3 rows)
359350

360351
select a from foo where a<1 and a>1 and not exists (select c from bar where c=a);
361352
a

src/test/regress/expected/partition_pruning.out

Lines changed: 47 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,8 +1102,7 @@ EXPLAIN SELECT * FROM pt_lt_tab WHERE col2 between 1 AND 50 ORDER BY col2,col3 L
11021102
-> Incremental Sort (cost=122.27..2022.42 rows=17 width=12)
11031103
Sort Key: pt_lt_tab.col2, pt_lt_tab.col3
11041104
Presorted Key: pt_lt_tab.col2
1105-
-> Merge Append (cost=0.73..2021.68 rows=17 width=12)
1106-
Sort Key: pt_lt_tab.col2
1105+
-> Append (cost=0.68..2021.42 rows=17 width=12)
11071106
-> Index Scan using idx1 on pt_lt_tab_1_prt_part1 pt_lt_tab_1 (cost=0.14..404.27 rows=3 width=12)
11081107
Index Cond: ((col2 >= '1'::numeric) AND (col2 <= '50'::numeric))
11091108
-> Index Scan using idx2 on pt_lt_tab_1_prt_part2 pt_lt_tab_2 (cost=0.14..404.27 rows=3 width=12)
@@ -1137,8 +1136,7 @@ EXPLAIN SELECT * FROM pt_lt_tab WHERE col2 > 5 ORDER BY col2,col3 LIMIT 5;
11371136
-> Incremental Sort (cost=123.40..1862.16 rows=15 width=12)
11381137
Sort Key: pt_lt_tab.col2, pt_lt_tab.col3
11391138
Presorted Key: pt_lt_tab.col2
1140-
-> Merge Append (cost=0.73..1861.48 rows=15 width=12)
1141-
Sort Key: pt_lt_tab.col2
1139+
-> Append (cost=0.68..1861.25 rows=15 width=12)
11421140
-> Index Scan using idx1 on pt_lt_tab_1_prt_part1 pt_lt_tab_1 (cost=0.14..244.20 rows=2 width=12)
11431141
Index Cond: (col2 > '5'::numeric)
11441142
-> Index Scan using idx2 on pt_lt_tab_1_prt_part2 pt_lt_tab_2 (cost=0.14..404.24 rows=3 width=12)
@@ -3400,37 +3398,45 @@ SELECT * FROM pt_bool_tab_df WHERE col2 IS unknown;
34003398
(1 row)
34013399

34023400
EXPLAIN SELECT * FROM pt_bool_tab_df WHERE col2 IS NOT true;
3403-
QUERY PLAN
3404-
-----------------------------------------------------------------------------------------------------------------------
3405-
Gather Motion 3:1 (slice1; segments: 3) (cost=10000000000.00..10000000969.00 rows=46750 width=5)
3406-
-> Seq Scan on pt_bool_tab_df_1_prt_part2 pt_bool_tab_df (cost=10000000000.00..10000000345.67 rows=15583 width=5)
3407-
Filter: (col2 IS NOT TRUE)
3401+
QUERY PLAN
3402+
-------------------------------------------------------------------------------------------------------------------------------
3403+
Gather Motion 3:1 (slice1; segments: 3) (cost=10000000000.00..20000002093.83 rows=93500 width=5)
3404+
-> Append (cost=10000000000.00..20000000847.17 rows=31167 width=5)
3405+
-> Seq Scan on pt_bool_tab_df_1_prt_part2 pt_bool_tab_df_1 (cost=10000000000.00..10000000345.67 rows=15583 width=5)
3406+
Filter: (col2 IS NOT TRUE)
3407+
-> Seq Scan on pt_bool_tab_df_1_prt_def pt_bool_tab_df_2 (cost=10000000000.00..10000000345.67 rows=15583 width=5)
3408+
Filter: (col2 IS NOT TRUE)
34083409
Optimizer: Postgres query optimizer
3409-
(4 rows)
3410+
(7 rows)
34103411

34113412
SELECT * FROM pt_bool_tab_df WHERE col2 IS NOT true;
34123413
col1 | col2
34133414
------+------
34143415
2 | f
34153416
1 | f
3416-
(2 rows)
3417+
1 |
3418+
(3 rows)
34173419

34183420
EXPLAIN SELECT * FROM pt_bool_tab_df WHERE col2 IS NOT false;
3419-
QUERY PLAN
3420-
-----------------------------------------------------------------------------------------------------------------------
3421-
Gather Motion 3:1 (slice1; segments: 3) (cost=10000000000.00..10000000969.00 rows=46750 width=5)
3422-
-> Seq Scan on pt_bool_tab_df_1_prt_part1 pt_bool_tab_df (cost=10000000000.00..10000000345.67 rows=15583 width=5)
3423-
Filter: (col2 IS NOT FALSE)
3421+
QUERY PLAN
3422+
-------------------------------------------------------------------------------------------------------------------------------
3423+
Gather Motion 3:1 (slice1; segments: 3) (cost=10000000000.00..20000002093.83 rows=93500 width=5)
3424+
-> Append (cost=10000000000.00..20000000847.17 rows=31167 width=5)
3425+
-> Seq Scan on pt_bool_tab_df_1_prt_part1 pt_bool_tab_df_1 (cost=10000000000.00..10000000345.67 rows=15583 width=5)
3426+
Filter: (col2 IS NOT FALSE)
3427+
-> Seq Scan on pt_bool_tab_df_1_prt_def pt_bool_tab_df_2 (cost=10000000000.00..10000000345.67 rows=15583 width=5)
3428+
Filter: (col2 IS NOT FALSE)
34243429
Optimizer: Postgres query optimizer
3425-
(4 rows)
3430+
(7 rows)
34263431

34273432
SELECT * FROM pt_bool_tab_df WHERE col2 IS NOT false;
34283433
col1 | col2
34293434
------+------
34303435
2 | t
34313436
3 | t
34323437
1 | t
3433-
(3 rows)
3438+
1 |
3439+
(4 rows)
34343440

34353441
EXPLAIN SELECT * FROM pt_bool_tab_df WHERE col2 IS NOT unknown;
34363442
QUERY PLAN
@@ -3740,37 +3746,45 @@ SELECT * FROM pt_bool_tab_null WHERE col2 IS unknown;
37403746
(1 row)
37413747

37423748
EXPLAIN SELECT * FROM pt_bool_tab_null WHERE col2 IS NOT true;
3743-
QUERY PLAN
3744-
---------------------------------------------------------------------------------------------------------------------------
3745-
Gather Motion 3:1 (slice1; segments: 3) (cost=10000000000.00..10000000969.00 rows=46750 width=5)
3746-
-> Seq Scan on pt_bool_tab_null_1_prt_part2 pt_bool_tab_null (cost=10000000000.00..10000000345.67 rows=15583 width=5)
3747-
Filter: (col2 IS NOT TRUE)
3749+
QUERY PLAN
3750+
-----------------------------------------------------------------------------------------------------------------------------------
3751+
Gather Motion 3:1 (slice1; segments: 3) (cost=10000000000.00..20000002093.83 rows=93500 width=5)
3752+
-> Append (cost=10000000000.00..20000000847.17 rows=31167 width=5)
3753+
-> Seq Scan on pt_bool_tab_null_1_prt_part2 pt_bool_tab_null_1 (cost=10000000000.00..10000000345.67 rows=15583 width=5)
3754+
Filter: (col2 IS NOT TRUE)
3755+
-> Seq Scan on pt_bool_tab_null_1_prt_part3 pt_bool_tab_null_2 (cost=10000000000.00..10000000345.67 rows=15583 width=5)
3756+
Filter: (col2 IS NOT TRUE)
37483757
Optimizer: Postgres query optimizer
3749-
(4 rows)
3758+
(7 rows)
37503759

37513760
SELECT * FROM pt_bool_tab_null WHERE col2 IS NOT true;
37523761
col1 | col2
37533762
------+------
3754-
1 | f
37553763
2 | f
3756-
(2 rows)
3764+
1 | f
3765+
1 |
3766+
(3 rows)
37573767

37583768
EXPLAIN SELECT * FROM pt_bool_tab_null WHERE col2 IS NOT false;
3759-
QUERY PLAN
3760-
---------------------------------------------------------------------------------------------------------------------------
3761-
Gather Motion 3:1 (slice1; segments: 3) (cost=10000000000.00..10000000969.00 rows=46750 width=5)
3762-
-> Seq Scan on pt_bool_tab_null_1_prt_part1 pt_bool_tab_null (cost=10000000000.00..10000000345.67 rows=15583 width=5)
3763-
Filter: (col2 IS NOT FALSE)
3769+
QUERY PLAN
3770+
-----------------------------------------------------------------------------------------------------------------------------------
3771+
Gather Motion 3:1 (slice1; segments: 3) (cost=10000000000.00..20000002093.83 rows=93500 width=5)
3772+
-> Append (cost=10000000000.00..20000000847.17 rows=31167 width=5)
3773+
-> Seq Scan on pt_bool_tab_null_1_prt_part1 pt_bool_tab_null_1 (cost=10000000000.00..10000000345.67 rows=15583 width=5)
3774+
Filter: (col2 IS NOT FALSE)
3775+
-> Seq Scan on pt_bool_tab_null_1_prt_part3 pt_bool_tab_null_2 (cost=10000000000.00..10000000345.67 rows=15583 width=5)
3776+
Filter: (col2 IS NOT FALSE)
37643777
Optimizer: Postgres query optimizer
3765-
(4 rows)
3778+
(7 rows)
37663779

37673780
SELECT * FROM pt_bool_tab_null WHERE col2 IS NOT false;
37683781
col1 | col2
37693782
------+------
37703783
2 | t
37713784
3 | t
37723785
1 | t
3773-
(3 rows)
3786+
1 |
3787+
(4 rows)
37743788

37753789
EXPLAIN SELECT * FROM pt_bool_tab_null WHERE col2 IS NOT unknown;
37763790
QUERY PLAN

src/test/regress/expected/subselect_gp.out

Lines changed: 9 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,40 +1132,20 @@ select * from t1 where a=1 and a=2 and a > (select t2.b from t2);
11321132
(0 rows)
11331133

11341134
explain select * from t1 where a=1 and a=2 and a > (select t2.b from t2);
1135-
QUERY PLAN
1136-
-------------------------------------------------------------------------------------------
1137-
Gather Motion 1:1 (slice1; segments: 1) (cost=1639.00..2154.52 rows=1 width=4)
1138-
InitPlan 1 (returns $0) (slice2)
1139-
-> Gather Motion 3:1 (slice3; segments: 3) (cost=0.00..1639.00 rows=96300 width=4)
1140-
-> Seq Scan on t2 (cost=0.00..355.00 rows=32100 width=4)
1141-
-> Result (cost=0.00..515.50 rows=1 width=4)
1142-
One-Time Filter: false
1143-
-> Seq Scan on t1 (cost=0.00..515.50 rows=1 width=4)
1144-
Filter: ((a > $0) AND (a = 1))
1135+
QUERY PLAN
1136+
------------------------------------------------
1137+
Result (cost=1639.00..1639.00 rows=0 width=0)
1138+
One-Time Filter: false
11451139
Optimizer: Postgres query optimizer
1146-
(9 rows)
1140+
(3 rows)
11471141

11481142
explain select * from t1 where a=1 and a=2 and a > (select t2.b from t2)
11491143
union all
11501144
select * from t1 where a=1 and a=2 and a > (select t2.b from t2);
1151-
QUERY PLAN
1152-
-------------------------------------------------------------------------------------------------------
1153-
Gather Motion 1:1 (slice1; segments: 1) (cost=1639.00..4309.09 rows=6 width=4)
1154-
-> Append (cost=1639.00..4309.01 rows=2 width=4)
1155-
-> Result (cost=1639.00..2154.50 rows=1 width=4)
1156-
One-Time Filter: false
1157-
InitPlan 1 (returns $0) (slice2)
1158-
-> Gather Motion 3:1 (slice3; segments: 3) (cost=0.00..1639.00 rows=96300 width=4)
1159-
-> Seq Scan on t2 (cost=0.00..355.00 rows=32100 width=4)
1160-
-> Seq Scan on t1 (cost=1639.00..2154.50 rows=1 width=4)
1161-
Filter: ((a > $0) AND (a = 1))
1162-
-> Result (cost=1639.00..2154.50 rows=1 width=4)
1163-
One-Time Filter: false
1164-
InitPlan 2 (returns $1) (slice4)
1165-
-> Gather Motion 3:1 (slice5; segments: 3) (cost=0.00..1639.00 rows=96300 width=4)
1166-
-> Seq Scan on t2 t2_1 (cost=0.00..355.00 rows=32100 width=4)
1167-
-> Seq Scan on t1 t1_1 (cost=1639.00..2154.50 rows=1 width=4)
1168-
Filter: ((a > $1) AND (a = 1))
1145+
QUERY PLAN
1146+
------------------------------------------
1147+
Result (cost=0.00..0.00 rows=0 width=0)
1148+
One-Time Filter: false
11691149
Optimizer: Postgres query optimizer
11701150
(3 rows)
11711151

src/test/regress/expected/update_gp.out

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -672,15 +672,13 @@ select * from s;
672672
-- constraints in the planner.
673673
create table nosplitupdate (a int) distributed by (a);
674674
explain update nosplitupdate set a=0 where a=1 and a<1;
675-
QUERY PLAN
676-
-----------------------------------------------------------------------------------------------------
677-
Update on nosplitupdate (cost=0.00..516.24 rows=0 width=0)
678-
-> Explicit Redistribute Motion 1:3 (slice1; segments: 1) (cost=0.00..516.24 rows=37 width=14)
679-
-> Split Update (cost=0.00..515.50 rows=37 width=14)
680-
-> Seq Scan on nosplitupdate (cost=0.00..515.50 rows=19 width=14)
681-
Filter: ((a < 1) AND (a = 1))
675+
QUERY PLAN
676+
-----------------------------------------------------------
677+
Update on nosplitupdate (cost=0.00..0.01 rows=0 width=0)
678+
-> Result (cost=0.00..0.00 rows=0 width=14)
679+
One-Time Filter: false
682680
Optimizer: Postgres query optimizer
683-
(6 rows)
681+
(4 rows)
684682

685683
-- test split-update when split-node's flow is entry
686684
create table tsplit_entry (c int);

0 commit comments

Comments
 (0)