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
Consider fractional paths in generate_orderedappend_paths
When building append paths, we've been looking only at startup and total
costs for the paths. When building fractional paths that may eliminate
the cheapest one, because it may be dominated by two separate paths (one
for startup, one for total cost).
This extends generate_orderedappend_paths() to also consider which paths
have lowest fractional cost. Currently we only consider paths matching
pathkeys - in the future this may be improved by also considering paths
that are only partially sorted, with an incremental sort on top.
Original report of an issue by Arne Roland, patch by me (based on a
suggestion by Tom Lane).
Reviewed-by: Arne Roland, Zhihong Yu
Discussion: https://postgr.es/m/e8f9ec90-546d-e948-acce-0525f3e92773%40enterprisedb.com
Discussion: https://postgr.es/m/1581042da8044e71ada2d6e3a51bf7bb%40index.de
Copy file name to clipboardExpand all lines: src/test/regress/sql/partition_join.sql
+25Lines changed: 25 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -1142,3 +1142,28 @@ SELECT t1.*, t2.* FROM alpha t1 INNER JOIN beta t2 ON (t1.a = t2.a AND t1.c = t2
1142
1142
EXPLAIN (COSTS OFF)
1143
1143
SELECT t1.*, t2.*FROM alpha t1 INNER JOIN beta t2 ON (t1.a=t2.aANDt1.b=t2.bANDt1.c=t2.c) WHERE ((t1.b>=100ANDt1.b<110) OR (t1.b>=200ANDt1.b<210)) AND ((t2.b>=100ANDt2.b<110) OR (t2.b>=200ANDt2.b<210)) ANDt1.cIN ('0004', '0009') ORDER BYt1.a, t1.b;
1144
1144
SELECT t1.*, t2.*FROM alpha t1 INNER JOIN beta t2 ON (t1.a=t2.aANDt1.b=t2.bANDt1.c=t2.c) WHERE ((t1.b>=100ANDt1.b<110) OR (t1.b>=200ANDt1.b<210)) AND ((t2.b>=100ANDt2.b<110) OR (t2.b>=200ANDt2.b<210)) ANDt1.cIN ('0004', '0009') ORDER BYt1.a, t1.b;
1145
+
1146
+
-- partitionwise join with fractional paths
1147
+
CREATETABLEfract_t (id BIGINT, PRIMARY KEY (id)) PARTITION BY RANGE (id);
1148
+
CREATETABLEfract_t0 PARTITION OF fract_t FOR VALUESFROM ('0') TO ('1000');
1149
+
CREATETABLEfract_t1 PARTITION OF fract_t FOR VALUESFROM ('1000') TO ('2000');
1150
+
1151
+
-- insert data
1152
+
INSERT INTO fract_t (id) (SELECT generate_series(0, 1999));
1153
+
ANALYZE fract_t;
1154
+
1155
+
-- verify plan; nested index only scans
1156
+
SET max_parallel_workers_per_gather =0;
1157
+
SET enable_partitionwise_join =on;
1158
+
1159
+
EXPLAIN (COSTS OFF)
1160
+
SELECT*FROM fract_t x LEFT JOIN fract_t y USING (id) ORDER BY id ASCLIMIT10;
1161
+
1162
+
EXPLAIN (COSTS OFF)
1163
+
SELECT*FROM fract_t x LEFT JOIN fract_t y USING (id) ORDER BY id DESCLIMIT10;
0 commit comments