postgresql/src/include/storage
Andres Freund 1804284042 Add parallel-aware hash joins.
Introduce parallel-aware hash joins that appear in EXPLAIN plans as Parallel
Hash Join with Parallel Hash.  While hash joins could already appear in
parallel queries, they were previously always parallel-oblivious and had a
partial subplan only on the outer side, meaning that the work of the inner
subplan was duplicated in every worker.

After this commit, the planner will consider using a partial subplan on the
inner side too, using the Parallel Hash node to divide the work over the
available CPU cores and combine its results in shared memory.  If the join
needs to be split into multiple batches in order to respect work_mem, then
workers process different batches as much as possible and then work together
on the remaining batches.

The advantages of a parallel-aware hash join over a parallel-oblivious hash
join 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 CPUs

One disadvantage is that there is some communication between the participating
CPUs which might outweigh the benefits of parallelism in the case of small
hash tables.  This is avoided by the planner's existing reluctance to supply
partial plans for small scans, but it may be necessary to estimate
synchronization costs in future if that situation changes.  Another is that
outer batch 0 must be written to disk if multiple batches are required.

A potential future advantage of parallel-aware hash joins is that right and
full outer joins could be supported, since there is a single set of matched
bits for each hashtable, but that is not yet implemented.

A new GUC enable_parallel_hash is defined to control the feature, defaulting
to on.

Author: Thomas Munro
Reviewed-By: Andres Freund, Robert Haas
Tested-By: Rafia Sabih, Prabhat Sahu
Discussion:
    https://postgr.es/m/CAEepm=2W=cOkiZxcg6qiFQP-dHUe09aqTrEMM7yJDrHMhDv_RA@mail.gmail.com
    https://postgr.es/m/CAEepm=37HKyJ4U6XOLi=JgfSHM3o6B-GaeO-6hkOmneTDkH+Uw@mail.gmail.com
2017-12-21 00:43:41 -08:00
..
.gitignore When trace_lwlocks is used, identify individual lwlocks by name. 2015-09-11 14:01:39 -04:00
backendid.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
barrier.h Add a barrier primitive for synchronizing backends. 2017-11-29 17:07:16 -08:00
block.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
buf.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
buf_internals.h pg_prewarm: Add automatic prewarm feature. 2017-08-21 14:17:39 -04:00
buffile.h Add infrastructure for sharing temporary files between backends. 2017-12-01 16:30:56 -08:00
bufmgr.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
bufpage.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
checksum.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
checksum_impl.h Update copyright via script for 2017 2017-01-03 13:48:53 -05:00
condition_variable.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
copydir.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
dsm.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
dsm_impl.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
fd.h Mark assorted variables PGDLLIMPORT. 2017-12-05 09:23:57 -05:00
freespace.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
fsm_internals.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
indexfsm.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
ipc.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
item.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
itemid.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
itemptr.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
large_object.h Refactor permissions checks for large objects. 2017-11-09 12:56:07 -05:00
latch.h Distinguish wait-for-connection from wait-for-write-ready on Windows. 2017-08-15 11:07:57 -04:00
lmgr.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
lock.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
lockdefs.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
lwlock.h Add parallel-aware hash joins. 2017-12-21 00:43:41 -08:00
off.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
pg_sema.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
pg_shmem.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
pmsignal.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
predicate.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
predicate_internals.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
proc.h Mark assorted variables PGDLLIMPORT. 2017-12-05 09:23:57 -05:00
procarray.h Phase 3 of pgindent updates. 2017-06-21 15:35:54 -04:00
proclist.h Update copyright via script for 2017 2017-01-03 13:48:53 -05:00
proclist_types.h Update copyright via script for 2017 2017-01-03 13:48:53 -05:00
procsignal.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
reinit.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
relfilenode.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
s_lock.h Add support for Motorola 88K to s_lock.h. 2017-11-20 18:05:17 -05:00
sharedfileset.h Add infrastructure for sharing temporary files between backends. 2017-12-01 16:30:56 -08:00
shm_mq.h Clean up shm_mq cleanup. 2017-08-31 15:10:24 -04:00
shm_toc.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
shmem.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
sinval.h Phase 3 of pgindent updates. 2017-06-21 15:35:54 -04:00
sinvaladt.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
smgr.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
spin.h Change TRUE/FALSE to true/false 2017-11-08 11:37:28 -05:00
standby.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
standbydefs.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00