You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Charge cpu_tuple_cost * 0.5 for Append and MergeAppend nodes.
Previously, Append didn't charge anything at all, and MergeAppend
charged only cpu_operator_cost, about half the value used here. This
change might make MergeAppend plans slightly more likely to be chosen
than before, since this commit increases the assumed cost for Append
-- with default values -- by 0.005 per tuple but MergeAppend by only
0.0025 per tuple. Since the comparisons required by MergeAppend are
costed separately, it's not clear why MergeAppend needs to be
otherwise more expensive than Append, so hopefully this is OK.
Prior to partition-wise join, it didn't really matter whether or not
an Append node had any cost of its own, because every plan had to use
the same number of Append or MergeAppend nodes and in the same places.
Only the relative cost of Append vs. MergeAppend made a difference.
Now, however, it is possible to avoid some of the Append nodes using a
partition-wise join, so it's worth making an effort. Pending patches
for partition-wise aggregate care too, because an Append of Aggregate
nodes will incur the Append overhead fewer times than an Aggregate
over an Append. Although in most cases this change will favor the use
of partition-wise techniques, it does the opposite when the join
cardinality is greater than the sum of the input cardinalities. Since
this situation arises in an existing regression test, I [rhaas]
adjusted it to keep the overall plan shape approximately the same.
Jeevan Chalke, per a suggestion from David Rowley. Reviewed by
Ashutosh Bapat. Some changes by me. The larger patch series of which
this patch is a part was also reviewed and tested by Antonin Houska,
Rajkumar Raghuwanshi, David Rowley, Dilip Kumar, Konstantin Knizhnik,
Pascal Legrand, Rafia Sabih, and me.
Discussion: http://postgr.es/m/CAKJS1f9UXdk6ZYyqbJnjFO9a9hyHKGW7B=ZRh-rxy9qxfPA5Gw@mail.gmail.com
Copy file name to clipboardExpand all lines: src/test/regress/expected/partition_join.out
+68-68Lines changed: 68 additions & 68 deletions
Original file line number
Diff line number
Diff line change
@@ -1144,59 +1144,59 @@ INSERT INTO plt1_e SELECT i, i, 'A' || to_char(i/50, 'FM0000') FROM generate_ser
1144
1144
ANALYZE plt1_e;
1145
1145
-- test partition matching with N-way join
1146
1146
EXPLAIN (COSTS OFF)
1147
-
SELECT avg(t1.a), avg(t2.b), avg(t3.a + t3.b), t1.c, t2.c, t3.c FROM plt1 t1, plt2 t2, plt1_e t3 WHERE t1.c = t2.c AND ltrim(t3.c, 'A') = t1.c GROUP BY t1.c, t2.c, t3.c ORDER BY t1.c, t2.c, t3.c;
1147
+
SELECT avg(t1.a), avg(t2.b), avg(t3.a + t3.b), t1.c, t2.c, t3.c FROM plt1 t1, plt2 t2, plt1_e t3 WHERE t1.b = t2.b AND t1.c = t2.c AND ltrim(t3.c, 'A') = t1.c GROUP BY t1.c, t2.c, t3.c ORDER BY t1.c, t2.c, t3.c;
Hash Cond: ((t1_1.b = t2_1.b) AND (t1_1.c = t2_1.c))
1169
+
-> Seq Scan on plt1_p2 t1_1
1170
+
-> Hash
1171
+
-> Seq Scan on plt2_p2 t2_1
1177
1172
-> Hash
1178
-
-> Hash Join
1179
-
Hash Cond: (t2_2.c = ltrim(t3_2.c, 'A'::text))
1173
+
-> Seq Scan on plt1_e_p2 t3_1
1174
+
-> Hash Join
1175
+
Hash Cond: (t1_2.c = ltrim(t3_2.c, 'A'::text))
1176
+
-> Hash Join
1177
+
Hash Cond: ((t1_2.b = t2_2.b) AND (t1_2.c = t2_2.c))
1178
+
-> Seq Scan on plt1_p3 t1_2
1179
+
-> Hash
1180
1180
-> Seq Scan on plt2_p3 t2_2
1181
-
-> Hash
1182
-
-> Seq Scan on plt1_e_p3 t3_2
1181
+
-> Hash
1182
+
-> Seq Scan on plt1_e_p3 t3_2
1183
1183
(33 rows)
1184
1184
1185
-
SELECT avg(t1.a), avg(t2.b), avg(t3.a + t3.b), t1.c, t2.c, t3.c FROM plt1 t1, plt2 t2, plt1_e t3 WHERE t1.c = t2.c AND ltrim(t3.c, 'A') = t1.c GROUP BY t1.c, t2.c, t3.c ORDER BY t1.c, t2.c, t3.c;
1185
+
SELECT avg(t1.a), avg(t2.b), avg(t3.a + t3.b), t1.c, t2.c, t3.c FROM plt1 t1, plt2 t2, plt1_e t3 WHERE t1.b = t2.b AND t1.c = t2.c AND ltrim(t3.c, 'A') = t1.c GROUP BY t1.c, t2.c, t3.c ORDER BY t1.c, t2.c, t3.c;
-- joins where one of the relations is proven empty
@@ -1289,59 +1289,59 @@ INSERT INTO pht1_e SELECT i, i, 'A' || to_char(i/50, 'FM0000') FROM generate_ser
1289
1289
ANALYZE pht1_e;
1290
1290
-- test partition matching with N-way join
1291
1291
EXPLAIN (COSTS OFF)
1292
-
SELECT avg(t1.a), avg(t2.b), avg(t3.a + t3.b), t1.c, t2.c, t3.c FROM pht1 t1, pht2 t2, pht1_e t3 WHERE t1.c = t2.c AND ltrim(t3.c, 'A') = t1.c GROUP BY t1.c, t2.c, t3.c ORDER BY t1.c, t2.c, t3.c;
SELECT avg(t1.a), avg(t2.b), avg(t3.a + t3.b), t1.c, t2.c, t3.c FROM pht1 t1, pht2 t2, pht1_e t3 WHERE t1.b = t2.b AND t1.c = t2.c AND ltrim(t3.c, 'A') = t1.c GROUP BY t1.c, t2.c, t3.c ORDER BY t1.c, t2.c, t3.c;
Hash Cond: ((t1_1.b = t2_1.b) AND (t1_1.c = t2_1.c))
1316
+
-> Seq Scan on pht1_p2 t1_1
1317
1317
-> Hash
1318
-
-> Seq Scan on pht1_e_p2 t3_1
1318
+
-> Seq Scan on pht2_p2 t2_1
1319
1319
-> Hash Join
1320
-
Hash Cond: (t1_2.c = t2_2.c)
1321
-
-> Seq Scan on pht1_p3 t1_2
1320
+
Hash Cond: (ltrim(t3_2.c, 'A'::text) = t1_2.c)
1321
+
-> Seq Scan on pht1_e_p3 t3_2
1322
1322
-> Hash
1323
1323
-> Hash Join
1324
-
Hash Cond: (t2_2.c = ltrim(t3_2.c, 'A'::text))
1325
-
-> Seq Scan on pht2_p3 t2_2
1324
+
Hash Cond: ((t1_2.b = t2_2.b) AND (t1_2.c = t2_2.c))
1325
+
-> Seq Scan on pht1_p3 t1_2
1326
1326
-> Hash
1327
-
-> Seq Scan on pht1_e_p3 t3_2
1327
+
-> Seq Scan on pht2_p3 t2_2
1328
1328
(33 rows)
1329
1329
1330
-
SELECT avg(t1.a), avg(t2.b), avg(t3.a + t3.b), t1.c, t2.c, t3.c FROM pht1 t1, pht2 t2, pht1_e t3 WHERE t1.c = t2.c AND ltrim(t3.c, 'A') = t1.c GROUP BY t1.c, t2.c, t3.c ORDER BY t1.c, t2.c, t3.c;
1330
+
SELECT avg(t1.a), avg(t2.b), avg(t3.a + t3.b), t1.c, t2.c, t3.c FROM pht1 t1, pht2 t2, pht1_e t3 WHERE t1.b = t2.b AND t1.c = t2.c AND ltrim(t3.c, 'A') = t1.c GROUP BY t1.c, t2.c, t3.c ORDER BY t1.c, t2.c, t3.c;
0 commit comments