forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit1804284
committed
Add parallel-aware hash joins.
Introduce parallel-aware hash joins that appear in EXPLAIN plans as ParallelHash Join with Parallel Hash. While hash joins could already appear inparallel queries, they were previously always parallel-oblivious and had apartial subplan only on the outer side, meaning that the work of the innersubplan was duplicated in every worker.After this commit, the planner will consider using a partial subplan on theinner side too, using the Parallel Hash node to divide the work over theavailable CPU cores and combine its results in shared memory. If the joinneeds to be split into multiple batches in order to respect work_mem, thenworkers process different batches as much as possible and then work togetheron the remaining batches.The advantages of a parallel-aware hash join over a parallel-oblivious hashjoin used in a parallel query are that it: * avoids wasting memory on duplicated hash tables * avoids wasting disk space on duplicated batch files * divides the work of building the hash table over the CPUsOne disadvantage is that there is some communication between the participatingCPUs which might outweigh the benefits of parallelism in the case of smallhash tables. This is avoided by the planner's existing reluctance to supplypartial plans for small scans, but it may be necessary to estimatesynchronization costs in future if that situation changes. Another is thatouter batch 0 must be written to disk if multiple batches are required.A potential future advantage of parallel-aware hash joins is that right andfull outer joins could be supported, since there is a single set of matchedbits for each hashtable, but that is not yet implemented.A new GUC enable_parallel_hash is defined to control the feature, defaultingto on.Author: Thomas MunroReviewed-By: Andres Freund, Robert HaasTested-By: Rafia Sabih, Prabhat SahuDiscussion:https://postgr.es/m/CAEepm=2W=cOkiZxcg6qiFQP-dHUe09aqTrEMM7yJDrHMhDv_RA@mail.gmail.comhttps://postgr.es/m/CAEepm=37HKyJ4U6XOLi=JgfSHM3o6B-GaeO-6hkOmneTDkH+Uw@mail.gmail.com1 parentf94eec4 commit1804284
File tree
30 files changed
+3091
-116
lines changed- doc/src/sgml
- src
- backend
- executor
- nodes
- optimizer
- path
- plan
- util
- postmaster
- utils/misc
- include
- executor
- nodes
- optimizer
- storage
- test/regress
- expected
- sql
- tools/pgindent
30 files changed
+3091
-116
lines changedLines changed: 15 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3647 | 3647 |
| |
3648 | 3648 |
| |
3649 | 3649 |
| |
| 3650 | + | |
| 3651 | + | |
| 3652 | + | |
| 3653 | + | |
| 3654 | + | |
| 3655 | + | |
| 3656 | + | |
| 3657 | + | |
| 3658 | + | |
| 3659 | + | |
| 3660 | + | |
| 3661 | + | |
| 3662 | + | |
| 3663 | + | |
| 3664 | + | |
3650 | 3665 |
| |
3651 | 3666 |
| |
3652 | 3667 |
| |
|
Lines changed: 61 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1263 | 1263 |
| |
1264 | 1264 |
| |
1265 | 1265 |
| |
1266 |
| - | |
| 1266 | + | |
1267 | 1267 |
| |
1268 | 1268 |
| |
1269 | 1269 |
| |
| |||
1279 | 1279 |
| |
1280 | 1280 |
| |
1281 | 1281 |
| |
| 1282 | + | |
| 1283 | + | |
| 1284 | + | |
| 1285 | + | |
| 1286 | + | |
| 1287 | + | |
| 1288 | + | |
| 1289 | + | |
| 1290 | + | |
| 1291 | + | |
| 1292 | + | |
| 1293 | + | |
| 1294 | + | |
| 1295 | + | |
| 1296 | + | |
| 1297 | + | |
| 1298 | + | |
| 1299 | + | |
| 1300 | + | |
| 1301 | + | |
| 1302 | + | |
| 1303 | + | |
| 1304 | + | |
| 1305 | + | |
| 1306 | + | |
| 1307 | + | |
| 1308 | + | |
| 1309 | + | |
| 1310 | + | |
| 1311 | + | |
| 1312 | + | |
| 1313 | + | |
| 1314 | + | |
| 1315 | + | |
| 1316 | + | |
| 1317 | + | |
| 1318 | + | |
| 1319 | + | |
| 1320 | + | |
| 1321 | + | |
| 1322 | + | |
| 1323 | + | |
| 1324 | + | |
| 1325 | + | |
| 1326 | + | |
| 1327 | + | |
| 1328 | + | |
| 1329 | + | |
| 1330 | + | |
| 1331 | + | |
| 1332 | + | |
| 1333 | + | |
| 1334 | + | |
| 1335 | + | |
| 1336 | + | |
| 1337 | + | |
| 1338 | + | |
| 1339 | + | |
| 1340 | + | |
| 1341 | + | |
1282 | 1342 |
| |
1283 | 1343 |
| |
1284 | 1344 |
| |
|
Lines changed: 21 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
31 | 31 |
| |
32 | 32 |
| |
33 | 33 |
| |
| 34 | + | |
34 | 35 |
| |
35 | 36 |
| |
36 | 37 |
| |
| |||
266 | 267 |
| |
267 | 268 |
| |
268 | 269 |
| |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
269 | 275 |
| |
270 | 276 |
| |
271 | 277 |
| |
| |||
474 | 480 |
| |
475 | 481 |
| |
476 | 482 |
| |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
477 | 488 |
| |
478 | 489 |
| |
479 | 490 |
| |
| |||
898 | 909 |
| |
899 | 910 |
| |
900 | 911 |
| |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
901 | 917 |
| |
902 | 918 |
| |
903 | 919 |
| |
| |||
1196 | 1212 |
| |
1197 | 1213 |
| |
1198 | 1214 |
| |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
1199 | 1220 |
| |
1200 | 1221 |
| |
1201 | 1222 |
| |
|
Lines changed: 3 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
770 | 770 |
| |
771 | 771 |
| |
772 | 772 |
| |
| 773 | + | |
| 774 | + | |
| 775 | + | |
773 | 776 |
| |
774 | 777 |
| |
775 | 778 |
| |
|
0 commit comments
Comments
(0)