diff -U3 /Users/smagen/projects/postgresql/env/master/src/src/test/regress/expected/inherit.out /Users/smagen/projects/postgresql/env/master/src/src/test/regress/results/inherit.out --- /Users/smagen/projects/postgresql/env/master/src/src/test/regress/expected/inherit.out 2025-09-07 11:27:22 +++ /Users/smagen/projects/postgresql/env/master/src/src/test/regress/results/inherit.out 2025-09-07 14:22:44 @@ -1842,21 +1842,25 @@ order by t1.b limit 10; QUERY PLAN ------------------------------------------------------------------------------------------------------ - Limit (cost=0.57..20.88 rows=10 width=16) - -> Merge Join (cost=0.57..189.37 rows=93 width=16) + Limit (cost=0.35..18.92 rows=10 width=16) + -> Merge Join (cost=0.35..173.11 rows=93 width=16) Merge Cond: (t1.b = t2.b) - -> Merge Append (cost=0.29..98.56 rows=1851 width=16) + -> Merge Append (cost=0.17..90.44 rows=1851 width=16) Sort Key: t1.b - -> Index Scan using matest0i on matest0 t1_1 (cost=0.12..8.14 rows=1 width=16) - -> Index Scan using matest1i on matest1 t1_2 (cost=0.15..71.90 rows=1850 width=16) - -> Materialize (cost=0.29..84.81 rows=10 width=4) - -> Merge Append (cost=0.29..84.78 rows=10 width=4) + -> Sort (cost=0.01..0.02 rows=1 width=16) + Sort Key: t1_1.b + -> Seq Scan on matest0 t1_1 (cost=0.00..0.00 rows=1 width=16) + -> Index Scan using matest1i on matest1 t1_2 (cost=0.15..71.90 rows=1850 width=16) + -> Materialize (cost=0.17..76.68 rows=10 width=4) + -> Merge Append (cost=0.17..76.65 rows=10 width=4) Sort Key: t2.b - -> Index Scan using matest0i on matest0 t2_1 (cost=0.12..8.14 rows=1 width=4) - Filter: (c = d) + -> Sort (cost=0.01..0.02 rows=1 width=4) + Sort Key: t2_1.b + -> Seq Scan on matest0 t2_1 (cost=0.00..0.00 rows=1 width=4) + Filter: (c = d) -> Index Scan using matest1i on matest1 t2_2 (cost=0.15..76.53 rows=9 width=4) Filter: (c = d) -(14 rows) +(18 rows) reset enable_nestloop; drop table matest0 cascade; diff -U3 /Users/smagen/projects/postgresql/env/master/src/src/test/regress/expected/union.out /Users/smagen/projects/postgresql/env/master/src/src/test/regress/results/union.out --- /Users/smagen/projects/postgresql/env/master/src/src/test/regress/expected/union.out 2025-09-07 11:27:30 +++ /Users/smagen/projects/postgresql/env/master/src/src/test/regress/results/union.out 2025-09-07 14:22:46 @@ -1205,14 +1205,16 @@ order by event_id; QUERY PLAN ------------------------------------------------------------------------------------------------ - Merge Append (cost=180.09..342.66 rows=5101 width=4) + Merge Append (cost=179.97..334.53 rows=5101 width=4) Sort Key: events.event_id - -> Index Scan using events_pkey on events (cost=0.12..8.14 rows=1 width=4) + -> Sort (cost=0.01..0.02 rows=1 width=4) + Sort Key: events.event_id + -> Seq Scan on events (cost=0.00..0.00 rows=1 width=4) -> Sort (cost=179.78..186.16 rows=2550 width=4) Sort Key: events_1.event_id -> Seq Scan on events_child events_1 (cost=0.00..35.50 rows=2550 width=4) -> Index Scan using other_events_pkey on other_events (cost=0.15..82.41 rows=2550 width=4) -(7 rows) +(9 rows) drop table events_child, events, other_events; reset enable_indexonlyscan; diff -U3 /Users/smagen/projects/postgresql/env/master/src/src/test/regress/expected/partition_join.out /Users/smagen/projects/postgresql/env/master/src/src/test/regress/results/partition_join.out --- /Users/smagen/projects/postgresql/env/master/src/src/test/regress/expected/partition_join.out 2025-09-07 11:27:39 +++ /Users/smagen/projects/postgresql/env/master/src/src/test/regress/results/partition_join.out 2025-09-07 14:23:04 @@ -65,31 +65,34 @@ -- inner join with partially-redundant join clauses EXPLAIN SELECT t1.a, t1.c, t2.b, t2.c FROM prt1 t1, prt2 t2 WHERE t1.a = t2.a AND t1.a = t2.b ORDER BY t1.a, t2.b; - QUERY PLAN ----------------------------------------------------------------------------------------------------- - Sort (cost=11.52..11.53 rows=3 width=18) + QUERY PLAN +---------------------------------------------------------------------------------------------- + Merge Append (cost=10.15..11.58 rows=3 width=18) Sort Key: t1.a - -> Append (cost=2.20..11.50 rows=3 width=18) - -> Merge Join (cost=2.20..3.58 rows=1 width=18) - Merge Cond: (t1_1.a = t2_1.a) - -> Index Scan using iprt1_p1_a on prt1_p1 t1_1 (cost=0.14..14.02 rows=125 width=9) - -> Sort (cost=2.06..2.06 rows=1 width=13) - Sort Key: t2_1.b - -> Seq Scan on prt2_p1 t2_1 (cost=0.00..2.05 rows=1 width=13) - Filter: (a = b) + -> Merge Join (cost=2.20..3.58 rows=1 width=18) + Merge Cond: (t1_1.a = t2_1.a) + -> Index Scan using iprt1_p1_a on prt1_p1 t1_1 (cost=0.14..14.02 rows=125 width=9) + -> Sort (cost=2.06..2.06 rows=1 width=13) + Sort Key: t2_1.b + -> Seq Scan on prt2_p1 t2_1 (cost=0.00..2.05 rows=1 width=13) + Filter: (a = b) + -> Sort (cost=4.79..4.79 rows=1 width=18) + Sort Key: t1_2.a -> Hash Join (cost=2.05..4.78 rows=1 width=18) Hash Cond: (t1_2.a = t2_2.a) -> Seq Scan on prt1_p2 t1_2 (cost=0.00..2.25 rows=125 width=9) -> Hash (cost=2.04..2.04 rows=1 width=13) -> Seq Scan on prt2_p2 t2_2 (cost=0.00..2.04 rows=1 width=13) Filter: (a = b) + -> Sort (cost=3.13..3.14 rows=1 width=18) + Sort Key: t1_3.a -> Hash Join (cost=1.43..3.12 rows=1 width=18) Hash Cond: (t1_3.a = t2_3.a) -> Seq Scan on prt1_p3 t1_3 (cost=0.00..1.50 rows=50 width=9) -> Hash (cost=1.41..1.41 rows=1 width=13) -> Seq Scan on prt2_p3 t2_3 (cost=0.00..1.41 rows=1 width=13) Filter: (a = b) -(22 rows) +(25 rows) SELECT t1.a, t1.c, t2.b, t2.c FROM prt1 t1, prt2 t2 WHERE t1.a = t2.a AND t1.a = t2.b ORDER BY t1.a, t2.b; a | c | b | c @@ -371,9 +374,10 @@ SELECT t1.* FROM prt1 t1 WHERE t1.a IN (SELECT t2.b FROM prt2 t2 WHERE t2.a = 0) AND t1.b = 0 ORDER BY t1.a; QUERY PLAN ------------------------------------------------------------------------------------ - Sort (cost=12.44..12.44 rows=3 width=13) + Merge Append (cost=10.79..12.50 rows=3 width=13) Sort Key: t1.a - -> Append (cost=2.10..12.41 rows=3 width=13) + -> Sort (cost=4.69..4.69 rows=1 width=13) + Sort Key: t1_1.a -> Hash Semi Join (cost=2.10..4.68 rows=1 width=13) Hash Cond: (t1_1.a = t2_1.b) -> Seq Scan on prt1_p1 t1_1 (cost=0.00..2.56 rows=5 width=13) @@ -381,6 +385,8 @@ -> Hash (cost=2.05..2.05 rows=4 width=4) -> Seq Scan on prt2_p1 t2_1 (cost=0.00..2.05 rows=4 width=4) Filter: (a = 0) + -> Sort (cost=4.66..4.67 rows=1 width=13) + Sort Key: t1_2.a -> Hash Semi Join (cost=2.08..4.65 rows=1 width=13) Hash Cond: (t1_2.a = t2_2.b) -> Seq Scan on prt1_p2 t1_2 (cost=0.00..2.56 rows=5 width=13) @@ -388,14 +394,16 @@ -> Hash (cost=2.04..2.04 rows=3 width=4) -> Seq Scan on prt2_p2 t2_2 (cost=0.00..2.04 rows=3 width=4) Filter: (a = 0) - -> Nested Loop Semi Join (cost=0.00..3.07 rows=1 width=13) - Join Filter: (t1_3.a = t2_3.b) - -> Seq Scan on prt1_p3 t1_3 (cost=0.00..1.62 rows=2 width=13) - Filter: (b = 0) - -> Materialize (cost=0.00..1.42 rows=1 width=4) + -> Nested Loop (cost=1.42..3.08 rows=1 width=13) + Join Filter: (t1_3.a = t2_3.b) + -> Unique (cost=1.42..1.43 rows=1 width=4) + -> Sort (cost=1.42..1.43 rows=1 width=4) + Sort Key: t2_3.b -> Seq Scan on prt2_p3 t2_3 (cost=0.00..1.41 rows=1 width=4) Filter: (a = 0) -(24 rows) + -> Seq Scan on prt1_p3 t1_3 (cost=0.00..1.62 rows=2 width=13) + Filter: (b = 0) +(29 rows) SELECT t1.* FROM prt1 t1 WHERE t1.a IN (SELECT t2.b FROM prt2 t2 WHERE t2.a = 0) AND t1.b = 0 ORDER BY t1.a; a | b | c @@ -1387,28 +1395,32 @@ -- This should generate a partitionwise join, but currently fails to EXPLAIN SELECT t1.a, t2.b FROM (SELECT * FROM prt1 WHERE a < 450) t1 LEFT JOIN (SELECT * FROM prt2 WHERE b > 250) t2 ON t1.a = t2.b WHERE t1.b = 0 ORDER BY t1.a, t2.b; - QUERY PLAN ---------------------------------------------------------------------------------------- - Incremental Sort (cost=14.03..15.02 rows=9 width=8) + QUERY PLAN +-------------------------------------------------------------------------------------------- + Sort (cost=14.23..14.25 rows=9 width=8) Sort Key: prt1.a, prt2.b - Presorted Key: prt1.a - -> Merge Left Join (cost=13.95..14.61 rows=9 width=8) - Merge Cond: (prt1.a = prt2.b) - -> Sort (cost=5.94..5.96 rows=9 width=4) - Sort Key: prt1.a - -> Append (cost=0.00..5.79 rows=9 width=4) - -> Seq Scan on prt1_p1 prt1_1 (cost=0.00..2.88 rows=5 width=4) - Filter: ((a < 450) AND (b = 0)) - -> Seq Scan on prt1_p2 prt1_2 (cost=0.00..2.88 rows=4 width=4) - Filter: ((a < 450) AND (b = 0)) - -> Sort (cost=8.01..8.30 rows=116 width=4) - Sort Key: prt2.b - -> Append (cost=0.00..4.03 rows=116 width=4) + -> Merge Right Join (cost=12.78..14.09 rows=9 width=8) + Merge Cond: (prt2.b = prt1.a) + -> Append (cost=6.93..7.80 rows=116 width=4) + -> Sort (cost=4.68..4.89 rows=83 width=4) + Sort Key: prt2_1.b -> Seq Scan on prt2_p2 prt2_1 (cost=0.00..2.04 rows=83 width=4) Filter: (b > 250) + -> Sort (cost=2.24..2.33 rows=33 width=4) + Sort Key: prt2_2.b -> Seq Scan on prt2_p3 prt2_2 (cost=0.00..1.41 rows=33 width=4) Filter: (b > 250) -(19 rows) + -> Materialize (cost=5.85..5.94 rows=9 width=4) + -> Append (cost=5.85..5.92 rows=9 width=4) + -> Sort (cost=2.93..2.95 rows=5 width=4) + Sort Key: prt1_1.a + -> Seq Scan on prt1_p1 prt1_1 (cost=0.00..2.88 rows=5 width=4) + Filter: ((a < 450) AND (b = 0)) + -> Sort (cost=2.92..2.92 rows=4 width=4) + Sort Key: prt1_2.a + -> Seq Scan on prt1_p2 prt1_2 (cost=0.00..2.88 rows=4 width=4) + Filter: ((a < 450) AND (b = 0)) +(23 rows) SELECT t1.a, t2.b FROM (SELECT * FROM prt1 WHERE a < 450) t1 LEFT JOIN (SELECT * FROM prt2 WHERE b > 250) t2 ON t1.a = t2.b WHERE t1.b = 0 ORDER BY t1.a, t2.b; a | b @@ -1428,25 +1440,33 @@ -- partitionwise join does not apply EXPLAIN SELECT t1.a, t2.b FROM prt1 t1, prt2 t2 WHERE t1::text = t2::text AND t1.a = t2.b ORDER BY t1.a; - QUERY PLAN ------------------------------------------------------------------------------------------ - Merge Join (cost=33.49..42.25 rows=1 width=8) - Merge Cond: ((t1.a = t2.b) AND (((((t1.*)::prt1))::text) = ((((t2.*)::prt2))::text))) - -> Sort (cost=19.84..20.59 rows=300 width=36) - Sort Key: t1.a, ((((t1.*)::prt1))::text) - -> Result (cost=0.00..7.50 rows=300 width=36) - -> Append (cost=0.00..7.50 rows=300 width=36) - -> Seq Scan on prt1_p1 t1_1 (cost=0.00..2.25 rows=125 width=36) - -> Seq Scan on prt1_p2 t1_2 (cost=0.00..2.25 rows=125 width=36) - -> Seq Scan on prt1_p3 t1_3 (cost=0.00..1.50 rows=50 width=36) - -> Sort (cost=13.64..14.14 rows=200 width=36) - Sort Key: t2.b, ((((t2.*)::prt2))::text) - -> Result (cost=0.00..6.00 rows=200 width=36) - -> Append (cost=0.00..6.00 rows=200 width=36) + QUERY PLAN +-------------------------------------------------------------------------------------- + Merge Join (cost=27.28..37.28 rows=1 width=8) + Merge Cond: (t1.a = t2.b) + Join Filter: ((((t2.*)::prt2))::text = (((t1.*)::prt1))::text) + -> Append (cost=16.12..18.37 rows=300 width=36) + -> Sort (cost=6.60..6.92 rows=125 width=36) + Sort Key: t1_1.a + -> Seq Scan on prt1_p1 t1_1 (cost=0.00..2.25 rows=125 width=36) + -> Sort (cost=6.60..6.92 rows=125 width=36) + Sort Key: t1_2.a + -> Seq Scan on prt1_p2 t1_2 (cost=0.00..2.25 rows=125 width=36) + -> Sort (cost=2.91..3.04 rows=50 width=36) + Sort Key: t1_3.a + -> Seq Scan on prt1_p3 t1_3 (cost=0.00..1.50 rows=50 width=36) + -> Materialize (cost=11.16..13.16 rows=200 width=36) + -> Append (cost=11.16..12.66 rows=200 width=36) + -> Sort (cost=4.52..4.73 rows=84 width=36) + Sort Key: t2_1.b -> Seq Scan on prt2_p1 t2_1 (cost=0.00..1.84 rows=84 width=36) + -> Sort (cost=4.48..4.68 rows=83 width=36) + Sort Key: t2_2.b -> Seq Scan on prt2_p2 t2_2 (cost=0.00..1.83 rows=83 width=36) + -> Sort (cost=2.16..2.24 rows=33 width=36) + Sort Key: t2_3.b -> Seq Scan on prt2_p3 t2_3 (cost=0.00..1.33 rows=33 width=36) -(16 rows) +(24 rows) SELECT t1.a, t2.b FROM prt1 t1, prt2 t2 WHERE t1::text = t2::text AND t1.a = t2.b ORDER BY t1.a; a | b @@ -4512,9 +4532,10 @@ SELECT t1.a, t1.c, t2.a, t2.c, t3.a, t3.c FROM plt1_adv t1 LEFT JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) LEFT JOIN plt1_adv t3 ON (t1.a = t3.a AND t1.c = t3.c) WHERE t1.b < 10 ORDER BY t1.a; QUERY PLAN ---------------------------------------------------------------------------------------------------- - Sort (cost=20.82..20.83 rows=4 width=34) + Merge Append (cost=19.81..20.94 rows=4 width=34) Sort Key: t1.a - -> Append (cost=3.84..20.78 rows=4 width=34) + -> Sort (cost=5.91..5.92 rows=1 width=34) + Sort Key: t1_1.a -> Hash Right Join (cost=3.84..5.90 rows=1 width=34) Hash Cond: ((t3_1.a = t1_1.a) AND (t3_1.c = t1_1.c)) -> Seq Scan on plt1_adv_p1 t3_1 (cost=0.00..1.60 rows=60 width=9) @@ -4525,6 +4546,8 @@ -> Hash (cost=1.75..1.75 rows=1 width=9) -> Seq Scan on plt1_adv_p1 t1_1 (cost=0.00..1.75 rows=1 width=9) Filter: (b < 10) + -> Sort (cost=5.91..5.92 rows=1 width=34) + Sort Key: t1_2.a -> Hash Right Join (cost=3.84..5.90 rows=1 width=34) Hash Cond: ((t3_2.a = t1_2.a) AND (t3_2.c = t1_2.c)) -> Seq Scan on plt1_adv_p2 t3_2 (cost=0.00..1.60 rows=60 width=9) @@ -4535,6 +4558,8 @@ -> Hash (cost=1.75..1.75 rows=1 width=9) -> Seq Scan on plt1_adv_p2 t1_2 (cost=0.00..1.75 rows=1 width=9) Filter: (b < 10) + -> Sort (cost=5.91..5.92 rows=1 width=34) + Sort Key: t1_3.a -> Hash Right Join (cost=3.84..5.90 rows=1 width=34) Hash Cond: ((t3_3.a = t1_3.a) AND (t3_3.c = t1_3.c)) -> Seq Scan on plt1_adv_p3 t3_3 (cost=0.00..1.60 rows=60 width=9) @@ -4545,15 +4570,19 @@ -> Hash (cost=1.75..1.75 rows=1 width=9) -> Seq Scan on plt1_adv_p3 t1_3 (cost=0.00..1.75 rows=1 width=9) Filter: (b < 10) - -> Nested Loop Left Join (cost=0.00..3.06 rows=1 width=34) - Join Filter: ((t1_4.a = t3_4.a) AND (t1_4.c = t3_4.c)) - -> Nested Loop Left Join (cost=0.00..2.04 rows=1 width=25) - Join Filter: ((t1_4.a = t2_4.a) AND (t1_4.c = t2_4.c)) + -> Nested Loop Left Join (cost=2.04..3.10 rows=1 width=34) + Join Filter: ((t1_4.a = t3_4.a) AND (t1_4.c = t3_4.c)) + -> Merge Left Join (cost=2.04..2.07 rows=1 width=25) + Merge Cond: ((t1_4.a = t2_4.a) AND (t1_4.c = t2_4.c)) + -> Sort (cost=1.02..1.03 rows=1 width=36) + Sort Key: t1_4.a, t1_4.c -> Seq Scan on plt1_adv_extra t1_4 (cost=0.00..1.01 rows=1 width=36) Filter: (b < 10) + -> Sort (cost=1.02..1.02 rows=1 width=36) + Sort Key: t2_4.a, t2_4.c -> Seq Scan on plt2_adv_extra t2_4 (cost=0.00..1.01 rows=1 width=36) - -> Seq Scan on plt1_adv_extra t3_4 (cost=0.00..1.01 rows=1 width=36) -(41 rows) + -> Seq Scan on plt1_adv_extra t3_4 (cost=0.00..1.01 rows=1 width=36) +(50 rows) SELECT t1.a, t1.c, t2.a, t2.c, t3.a, t3.c FROM plt1_adv t1 LEFT JOIN plt2_adv t2 ON (t1.a = t2.a AND t1.c = t2.c) LEFT JOIN plt1_adv t3 ON (t1.a = t3.a AND t1.c = t3.c) WHERE t1.b < 10 ORDER BY t1.a; a | c | a | c | a | c diff -U3 /Users/smagen/projects/postgresql/env/master/src/src/test/regress/expected/partition_prune.out /Users/smagen/projects/postgresql/env/master/src/src/test/regress/results/partition_prune.out --- /Users/smagen/projects/postgresql/env/master/src/src/test/regress/expected/partition_prune.out 2025-09-07 11:29:17 +++ /Users/smagen/projects/postgresql/env/master/src/src/test/regress/results/partition_prune.out 2025-09-07 14:23:04 @@ -4762,15 +4762,16 @@ select min(a) over (partition by a order by a) from part_abc where a >= stable_one() + 1 and d >= stable_one(); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------ - Append (cost=3.21..1271.00 rows=1050 width=4) - -> Subquery Scan on "*SELECT* 1_1" (cost=3.21..632.87 rows=525 width=4) - -> WindowAgg (cost=3.21..627.62 rows=525 width=8) + Append (cost=4.35..1256.77 rows=1050 width=4) + -> Subquery Scan on "*SELECT* 1_1" (cost=4.35..625.76 rows=525 width=4) + -> WindowAgg (cost=4.35..620.51 rows=525 width=8) Window: w1 AS (PARTITION BY part_abc.a ORDER BY part_abc.a) - -> Append (cost=2.02..618.44 rows=525 width=4) + -> Append (cost=3.17..611.32 rows=525 width=4) Subplans Removed: 1 - -> Index Scan using part_abc_2_a_idx on part_abc_2 part_abc_1 (cost=0.38..8.65 rows=1 width=4) - Index Cond: (a >= (stable_one() + 1)) - Filter: (d <= stable_one()) + -> Sort (cost=1.53..1.53 rows=1 width=4) + Sort Key: part_abc_1.a + -> Seq Scan on part_abc_2 part_abc_1 (cost=0.00..1.52 rows=1 width=4) + Filter: ((d <= stable_one()) AND (a >= (stable_one() + 1))) -> Merge Append (cost=1.24..456.65 rows=393 width=4) Sort Key: part_abc_3.a Subplans Removed: 1 @@ -4780,14 +4781,15 @@ -> Index Scan using part_abc_3_2_a_idx on part_abc_3_2 part_abc_4 (cost=0.41..150.52 rows=131 width=4) Index Cond: (a >= (stable_one() + 1)) Filter: (d <= stable_one()) - -> Subquery Scan on "*SELECT* 2" (cost=3.21..632.87 rows=525 width=4) - -> WindowAgg (cost=3.21..627.62 rows=525 width=8) + -> Subquery Scan on "*SELECT* 2" (cost=4.35..625.76 rows=525 width=4) + -> WindowAgg (cost=4.35..620.51 rows=525 width=8) Window: w1 AS (PARTITION BY part_abc_5.a ORDER BY part_abc_5.a) - -> Append (cost=2.02..618.44 rows=525 width=4) + -> Append (cost=3.17..611.32 rows=525 width=4) Subplans Removed: 1 - -> Index Scan using part_abc_2_a_idx on part_abc_2 part_abc_6 (cost=0.38..8.65 rows=1 width=4) - Index Cond: (a >= (stable_one() + 1)) - Filter: (d >= stable_one()) + -> Sort (cost=1.53..1.53 rows=1 width=4) + Sort Key: part_abc_6.a + -> Seq Scan on part_abc_2 part_abc_6 (cost=0.00..1.52 rows=1 width=4) + Filter: ((d >= stable_one()) AND (a >= (stable_one() + 1))) -> Merge Append (cost=1.24..456.65 rows=393 width=4) Sort Key: a Subplans Removed: 1 @@ -4797,7 +4799,7 @@ -> Index Scan using part_abc_3_3_a_idx on part_abc_3_3 part_abc_9 (cost=0.41..150.52 rows=131 width=4) Index Cond: (a >= (stable_one() + 1)) Filter: (d >= stable_one()) -(35 rows) +(37 rows) drop view part_abc_view; drop table part_abc;