diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/executor/nodeHash.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/backend/executor/nodeHash.c b/src/backend/executor/nodeHash.c index 570a90ebe15..0456a017dc6 100644 --- a/src/backend/executor/nodeHash.c +++ b/src/backend/executor/nodeHash.c @@ -1228,6 +1228,7 @@ ExecParallelHashIncreaseNumBatches(HashJoinTable hashtable) if (BarrierArriveAndWait(&pstate->grow_batches_barrier, WAIT_EVENT_HASH_GROW_BATCHES_DECIDE)) { + ParallelHashJoinBatch *old_batches; bool space_exhausted = false; bool extreme_skew_detected = false; @@ -1235,25 +1236,31 @@ ExecParallelHashIncreaseNumBatches(HashJoinTable hashtable) ExecParallelHashEnsureBatchAccessors(hashtable); ExecParallelHashTableSetCurrentBatch(hashtable, 0); + old_batches = dsa_get_address(hashtable->area, pstate->old_batches); + /* Are any of the new generation of batches exhausted? */ for (int i = 0; i < hashtable->nbatch; ++i) { - ParallelHashJoinBatch *batch = hashtable->batches[i].shared; + ParallelHashJoinBatch *batch; + ParallelHashJoinBatch *old_batch; + int parent; + batch = hashtable->batches[i].shared; if (batch->space_exhausted || batch->estimated_size > pstate->space_allowed) - { - int parent; - space_exhausted = true; + parent = i % pstate->old_nbatch; + old_batch = NthParallelHashJoinBatch(old_batches, parent); + if (old_batch->space_exhausted || + batch->estimated_size > pstate->space_allowed) + { /* * Did this batch receive ALL of the tuples from its * parent batch? That would indicate that further * repartitioning isn't going to help (the hash values * are probably all the same). */ - parent = i % pstate->old_nbatch; if (batch->ntuples == hashtable->batches[parent].shared->old_ntuples) extreme_skew_detected = true; } |