- Notifications
You must be signed in to change notification settings - Fork28
Commit624e440
committed
Improve the heuristic for ordering child paths of a parallel append.
Commitab72716 introduced code that attempts to order the childscans of a Parallel Append node in a way that will minimize executiontime, based on total cost and startup cost. However, it failed tothink hard about what to do when estimated costs are exactly equal;a case that's particularly likely to occur when comparing on startupcost. In such a case the ordering of the child paths would be leftto the whims of qsort, an algorithm that isn't even stable.We can improve matters by applying the rule used elsewhere in theplanner: if total costs are equal, sort on startup cost, andvice versa. When both cost estimates are exactly equal, ratherthan letting qsort do something unpredictable, sort based on thechild paths' relids, which should typically result in sorting ininheritance order. (The latter provision requires inventing aqsort-style comparator for bitmapsets, but maybe we'll have usefor that for other reasons in future.)This results in a few plan changes in the select_parallel test,but those all look more reasonable than before, when the actualunderlying cost numbers are taken into account.Discussion:https://postgr.es/m/4944.1515446989@sss.pgh.pa.us1 parent80259d4 commit624e440
File tree
4 files changed
+73
-22
lines changed- src
- backend
- nodes
- optimizer/util
- include/nodes
- test/regress/expected
4 files changed
+73
-22
lines changedLines changed: 45 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
172 | 172 |
| |
173 | 173 |
| |
174 | 174 |
| |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
175 | 219 |
| |
176 | 220 |
| |
177 | 221 |
| |
| |||
838 | 882 |
| |
839 | 883 |
| |
840 | 884 |
| |
841 |
| - | |
| 885 | + | |
842 | 886 |
| |
843 | 887 |
| |
844 | 888 |
| |
|
Lines changed: 20 additions & 14 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1274 | 1274 |
| |
1275 | 1275 |
| |
1276 | 1276 |
| |
1277 |
| - | |
| 1277 | + | |
| 1278 | + | |
| 1279 | + | |
| 1280 | + | |
| 1281 | + | |
1278 | 1282 |
| |
1279 | 1283 |
| |
1280 | 1284 |
| |
1281 | 1285 |
| |
1282 | 1286 |
| |
1283 | 1287 |
| |
| 1288 | + | |
1284 | 1289 |
| |
1285 |
| - | |
1286 |
| - | |
1287 |
| - | |
1288 |
| - | |
1289 |
| - | |
1290 |
| - | |
| 1290 | + | |
| 1291 | + | |
| 1292 | + | |
| 1293 | + | |
1291 | 1294 |
| |
1292 | 1295 |
| |
1293 | 1296 |
| |
1294 | 1297 |
| |
1295 |
| - | |
| 1298 | + | |
| 1299 | + | |
| 1300 | + | |
| 1301 | + | |
| 1302 | + | |
1296 | 1303 |
| |
1297 | 1304 |
| |
1298 | 1305 |
| |
1299 | 1306 |
| |
1300 | 1307 |
| |
1301 | 1308 |
| |
| 1309 | + | |
1302 | 1310 |
| |
1303 |
| - | |
1304 |
| - | |
1305 |
| - | |
1306 |
| - | |
1307 |
| - | |
1308 |
| - | |
| 1311 | + | |
| 1312 | + | |
| 1313 | + | |
| 1314 | + | |
1309 | 1315 |
| |
1310 | 1316 |
| |
1311 | 1317 |
| |
|
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
65 | 65 |
| |
66 | 66 |
| |
67 | 67 |
| |
| 68 | + | |
68 | 69 |
| |
69 | 70 |
| |
70 | 71 |
| |
|
Lines changed: 7 additions & 7 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
21 | 21 |
| |
22 | 22 |
| |
23 | 23 |
| |
24 |
| - | |
25 |
| - | |
26 |
| - | |
27 | 24 |
| |
28 |
| - | |
29 | 25 |
| |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
30 | 30 |
| |
31 | 31 |
| |
32 | 32 |
| |
| |||
49 | 49 |
| |
50 | 50 |
| |
51 | 51 |
| |
52 |
| - | |
53 |
| - | |
54 |
| - | |
55 | 52 |
| |
| 53 | + | |
| 54 | + | |
| 55 | + | |
56 | 56 |
| |
57 | 57 |
| |
58 | 58 |
| |
|
0 commit comments
Comments
(0)