PostgreSQL Source Code git master
|
Go to the source code of this file.
void ExecChooseHashTableSize | ( | double | ntuples, |
int | tupwidth, | ||
bool | useskew, | ||
bool | try_combined_hash_mem, | ||
int | parallel_workers, | ||
size_t * | space_allowed, | ||
int * | numbuckets, | ||
int * | numbatches, | ||
int * | num_skew_mcvs | ||
) |
Definition at line 658 of file nodeHash.c.
References Assert, ExecChooseHashTableSize(), get_hash_memory_limit(), HJTUPLE_OVERHEAD, Max, MAXALIGN, MaxAllocSize, Min, NTUP_PER_BUCKET, pg_nextpower2_32(), pg_nextpower2_size_t, pg_prevpower2_size_t, SizeofMinimalTupleHeader, SKEW_BUCKET_OVERHEAD, and SKEW_HASH_MEM_PERCENT.
Referenced by ExecChooseHashTableSize(), ExecHashTableCreate(), and initial_cost_hashjoin().
void ExecEndHash | ( | HashState * | node | ) |
Definition at line 427 of file nodeHash.c.
References ExecEndNode(), outerPlan, and outerPlanState.
Referenced by ExecEndNode().
void ExecHashAccumInstrumentation | ( | HashInstrumentation * | instrument, |
HashJoinTable | hashtable | ||
) |
Definition at line 2742 of file nodeHash.c.
References Max, HashJoinTableData::nbatch, HashInstrumentation::nbatch, HashJoinTableData::nbatch_original, HashInstrumentation::nbatch_original, HashJoinTableData::nbuckets, HashInstrumentation::nbuckets, HashJoinTableData::nbuckets_original, HashInstrumentation::nbuckets_original, HashInstrumentation::space_peak, and HashJoinTableData::spacePeak.
Referenced by ExecReScanHashJoin(), and ExecShutdownHash().
void ExecHashEstimate | ( | HashState * | node, |
ParallelContext * | pcxt | ||
) |
Definition at line 2626 of file nodeHash.c.
References add_size(), ParallelContext::estimator, PlanState::instrument, mul_size(), ParallelContext::nworkers, HashState::ps, shm_toc_estimate_chunk, shm_toc_estimate_keys, and size.
Referenced by ExecParallelEstimate().
void ExecHashGetBucketAndBatch | ( | HashJoinTable | hashtable, |
uint32 | hashvalue, | ||
int * | bucketno, | ||
int * | batchno | ||
) |
Definition at line 1825 of file nodeHash.c.
References HashJoinTableData::log2_nbuckets, HashJoinTableData::nbatch, HashJoinTableData::nbuckets, and pg_rotate_right32().
Referenced by ExecHashIncreaseNumBatches(), ExecHashIncreaseNumBuckets(), ExecHashJoinImpl(), ExecHashRemoveNextSkewBucket(), ExecHashTableInsert(), ExecParallelHashIncreaseNumBuckets(), ExecParallelHashJoinPartitionOuter(), ExecParallelHashRepartitionFirst(), ExecParallelHashRepartitionRest(), ExecParallelHashTableInsert(), and ExecParallelHashTableInsertCurrentBatch().
int ExecHashGetSkewBucket | ( | HashJoinTable | hashtable, |
uint32 | hashvalue | ||
) |
Definition at line 2420 of file nodeHash.c.
References HashSkewBucket::hashvalue, INVALID_SKEW_BUCKET_NO, HashJoinTableData::skewBucket, HashJoinTableData::skewBucketLen, and HashJoinTableData::skewEnabled.
Referenced by ExecHashJoinImpl(), and MultiExecPrivateHash().
void ExecHashInitializeDSM | ( | HashState * | node, |
ParallelContext * | pcxt | ||
) |
Definition at line 2645 of file nodeHash.c.
References PlanState::instrument, SharedHashInfo::num_workers, ParallelContext::nworkers, PlanState::plan, Plan::plan_node_id, HashState::ps, HashState::shared_info, shm_toc_allocate(), shm_toc_insert(), size, and ParallelContext::toc.
Referenced by ExecParallelInitializeDSM().
void ExecHashInitializeWorker | ( | HashState * | node, |
ParallelWorkerContext * | pwcxt | ||
) |
Definition at line 2670 of file nodeHash.c.
References SharedHashInfo::hinstrument, HashState::hinstrument, PlanState::instrument, ParallelWorkerNumber, PlanState::plan, Plan::plan_node_id, HashState::ps, shm_toc_lookup(), and ParallelWorkerContext::toc.
Referenced by ExecParallelInitializeWorker().
void ExecHashRetrieveInstrumentation | ( | HashState * | node | ) |
Definition at line 2711 of file nodeHash.c.
References SharedHashInfo::num_workers, palloc(), HashState::shared_info, and size.
Referenced by ExecParallelRetrieveInstrumentation().
HashJoinTable ExecHashTableCreate | ( | HashState * | state | ) |
Definition at line 446 of file nodeHash.c.
References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, HashJoinTableData::area, Assert, BarrierArriveAndWait(), BarrierAttach(), BarrierPhase(), HashJoinTableData::batchCxt, HashJoinTableData::batches, HashJoinTableData::buckets, ParallelHashJoinState::build_barrier, HashJoinTableData::chunks, HashJoinTableData::curbatch, HashJoinTableData::current_chunk, CurrentMemoryContext, ExecChooseHashTableSize(), ExecHashBuildSkewHash(), ExecParallelHashJoinSetUpBatches(), ExecParallelHashTableAlloc(), HashJoinTableData::growEnabled, ParallelHashJoinState::growth, HashJoinTableData::hashCxt, HashJoinTableData::innerBatchFile, HashJoinTableData::log2_nbuckets, HashJoinTableData::log2_nbuckets_optimal, MemoryContextSwitchTo(), my_log2(), ParallelHashJoinState::nbatch, HashJoinTableData::nbatch, HashJoinTableData::nbatch_original, HashJoinTableData::nbatch_outstart, ParallelHashJoinState::nbuckets, HashJoinTableData::nbuckets, HashJoinTableData::nbuckets_optimal, HashJoinTableData::nbuckets_original, HashJoinTableData::nSkewBuckets, OidIsValid, HashJoinTableData::outerBatchFile, outerPlan, palloc0_array, palloc_object, Plan::parallel_aware, HashJoinTableData::parallel_state, HashJoinTableData::partialTuples, PHJ_BUILD_ELECT, PHJ_GROWTH_OK, Hash::plan, Plan::plan_rows, Plan::plan_width, PrepareTempTablespaces(), printf, Hash::rows_total, SKEW_HASH_MEM_PERCENT, HashJoinTableData::skewBucket, HashJoinTableData::skewBucketLen, HashJoinTableData::skewBucketNums, HashJoinTableData::skewEnabled, Hash::skewTable, HashJoinTableData::skewTuples, ParallelHashJoinState::space_allowed, HashJoinTableData::spaceAllowed, HashJoinTableData::spaceAllowedSkew, HashJoinTableData::spacePeak, HashJoinTableData::spaceUsed, HashJoinTableData::spaceUsedSkew, HashJoinTableData::spillCxt, HashJoinTableData::totalTuples, and HashJoinTableData::unshared.
Referenced by ExecHashJoinImpl().
void ExecHashTableDestroy | ( | HashJoinTable | hashtable | ) |
Definition at line 866 of file nodeHash.c.
References BufFileClose(), HashJoinTableData::hashCxt, i, HashJoinTableData::innerBatchFile, MemoryContextDelete(), HashJoinTableData::nbatch, HashJoinTableData::outerBatchFile, and pfree().
Referenced by ExecEndHashJoin(), and ExecReScanHashJoin().
void ExecHashTableDetach | ( | HashJoinTable | hashtable | ) |
Definition at line 3266 of file nodeHash.c.
References HashJoinTableData::area, Assert, BarrierArriveAndDetach(), BarrierPhase(), ParallelHashJoinState::batches, HashJoinTableData::batches, ParallelHashJoinState::build_barrier, dsa_free(), DsaPointerIsValid, i, ParallelHashJoinBatchAccessor::inner_tuples, InvalidDsaPointer, HashJoinTableData::nbatch, ParallelHashJoinBatchAccessor::outer_tuples, HashJoinTableData::parallel_state, PHJ_BUILD_FREE, PHJ_BUILD_RUN, sts_end_parallel_scan(), and sts_end_write().
Referenced by ExecHashJoinReInitializeDSM(), and ExecShutdownHashJoin().
void ExecHashTableDetachBatch | ( | HashJoinTable | hashtable | ) |
Definition at line 3174 of file nodeHash.c.
References HashJoinTableData::area, Assert, BarrierArriveAndDetach(), BarrierArriveAndDetachExceptLast(), BarrierPhase(), ParallelHashJoinBatch::batch_barrier, HashJoinTableData::batches, ParallelHashJoinBatch::buckets, chunk, ParallelHashJoinBatch::chunks, HashJoinTableData::curbatch, dsa_free(), dsa_get_address(), DsaPointerIsValid, ParallelHashJoinBatchAccessor::inner_tuples, InvalidDsaPointer, Max, HashJoinTableData::nbuckets, next, ParallelHashJoinBatchAccessor::outer_eof, ParallelHashJoinBatchAccessor::outer_tuples, HashJoinTableData::parallel_state, PHJ_BATCH_FREE, PHJ_BATCH_PROBE, PHJ_BATCH_SCAN, ParallelHashJoinBatchAccessor::shared, ParallelHashJoinBatch::size, ParallelHashJoinBatch::skip_unmatched, HashJoinTableData::spacePeak, and sts_end_parallel_scan().
Referenced by ExecHashJoinReInitializeDSM(), ExecParallelHashJoinNewBatch(), ExecParallelPrepHashTableForUnmatched(), and ExecShutdownHashJoin().
void ExecHashTableInsert | ( | HashJoinTable | hashtable, |
TupleTableSlot * | slot, | ||
uint32 | hashvalue | ||
) |
Definition at line 1614 of file nodeHash.c.
References Assert, HashJoinTableData::buckets, HashJoinTableData::curbatch, dense_alloc(), ExecFetchSlotMinimalTuple(), ExecHashGetBucketAndBatch(), ExecHashIncreaseNumBatches(), ExecHashJoinSaveTuple(), HashJoinTupleData::hashvalue, heap_free_minimal_tuple(), HeapTupleHeaderClearMatch, HJTUPLE_MINTUPLE, HJTUPLE_OVERHEAD, HashJoinTableData::innerBatchFile, HashJoinTableData::log2_nbuckets_optimal, MaxAllocSize, HashJoinTableData::nbatch, HashJoinTableData::nbuckets_optimal, HashJoinTupleData::next, NTUP_PER_BUCKET, HashJoinTableData::skewTuples, HashJoinTableData::spaceAllowed, HashJoinTableData::spacePeak, HashJoinTableData::spaceUsed, MinimalTupleData::t_len, HashJoinTableData::totalTuples, HashJoinTupleData::unshared, and HashJoinTableData::unshared.
Referenced by ExecHashJoinNewBatch(), and MultiExecPrivateHash().
void ExecHashTableReset | ( | HashJoinTable | hashtable | ) |
Definition at line 2192 of file nodeHash.c.
References HashJoinTableData::batchCxt, HashJoinTableData::buckets, HashJoinTableData::chunks, MemoryContextReset(), MemoryContextSwitchTo(), HashJoinTableData::nbuckets, palloc0_array, HashJoinTableData::spaceUsed, and HashJoinTableData::unshared.
Referenced by ExecHashJoinNewBatch().
void ExecHashTableResetMatchFlags | ( | HashJoinTable | hashtable | ) |
Definition at line 2220 of file nodeHash.c.
References HashJoinTableData::buckets, HeapTupleHeaderClearMatch, HJTUPLE_MINTUPLE, i, j, HashJoinTableData::nbuckets, HashJoinTupleData::next, HashJoinTableData::nSkewBuckets, HashJoinTableData::skewBucket, HashJoinTableData::skewBucketNums, HashSkewBucket::tuples, HashJoinTupleData::unshared, and HashJoinTableData::unshared.
Referenced by ExecReScanHashJoin().
Definition at line 370 of file nodeHash.c.
References Assert, EXEC_FLAG_BACKWARD, EXEC_FLAG_MARK, ExecAssignExprContext(), ExecHash(), ExecInitNode(), ExecInitResultTupleSlotTL(), PlanState::ExecProcNode, HashState::hash_expr, HashState::hashtable, makeNode, NIL, outerPlan, outerPlanState, PlanState::plan, Hash::plan, HashState::ps, PlanState::ps_ProjInfo, Plan::qual, PlanState::state, and TTSOpsMinimalTuple.
Referenced by ExecInitNode().
void ExecParallelHashTableAlloc | ( | HashJoinTable | hashtable, |
int | batchno | ||
) |
Definition at line 3154 of file nodeHash.c.
References HashJoinTableData::area, HashJoinTableData::batches, ParallelHashJoinBatch::buckets, dsa_allocate, dsa_get_address(), dsa_pointer_atomic_init, i, InvalidDsaPointer, ParallelHashJoinState::nbuckets, HashJoinTableData::parallel_state, and ParallelHashJoinBatchAccessor::shared.
Referenced by ExecHashTableCreate(), and ExecParallelHashJoinNewBatch().
void ExecParallelHashTableInsert | ( | HashJoinTable | hashtable, |
TupleTableSlot * | slot, | ||
uint32 | hashvalue | ||
) |
Definition at line 1704 of file nodeHash.c.
References Assert, BarrierPhase(), HashJoinTableData::batches, HashJoinTableData::buckets, ParallelHashJoinState::build_barrier, ExecFetchSlotMinimalTuple(), ExecHashGetBucketAndBatch(), ExecParallelHashPushTuple(), ExecParallelHashTupleAlloc(), ExecParallelHashTuplePrealloc(), HashJoinTupleData::hashvalue, heap_free_minimal_tuple(), HeapTupleHeaderClearMatch, HJTUPLE_MINTUPLE, HJTUPLE_OVERHEAD, ParallelHashJoinBatchAccessor::inner_tuples, MAXALIGN, ParallelHashJoinBatchAccessor::ntuples, HashJoinTableData::parallel_state, PHJ_BUILD_HASH_INNER, ParallelHashJoinBatchAccessor::preallocated, HashJoinTableData::shared, sts_puttuple(), and MinimalTupleData::t_len.
Referenced by MultiExecParallelHash().
void ExecParallelHashTableInsertCurrentBatch | ( | HashJoinTable | hashtable, |
TupleTableSlot * | slot, | ||
uint32 | hashvalue | ||
) |
Definition at line 1770 of file nodeHash.c.
References Assert, HashJoinTableData::buckets, HashJoinTableData::curbatch, ExecFetchSlotMinimalTuple(), ExecHashGetBucketAndBatch(), ExecParallelHashPushTuple(), ExecParallelHashTupleAlloc(), HashJoinTupleData::hashvalue, heap_free_minimal_tuple(), HeapTupleHeaderClearMatch, HJTUPLE_MINTUPLE, HJTUPLE_OVERHEAD, HashJoinTableData::shared, and MinimalTupleData::t_len.
Referenced by ExecParallelHashJoinNewBatch().
void ExecParallelHashTableSetCurrentBatch | ( | HashJoinTable | hashtable, |
int | batchno | ||
) |
Definition at line 3364 of file nodeHash.c.
References HashJoinTableData::area, Assert, ParallelHashJoinBatchAccessor::at_least_one_chunk, HashJoinTableData::batches, ParallelHashJoinBatch::buckets, HashJoinTableData::buckets, HashJoinTableData::curbatch, HashJoinTableData::current_chunk, HashJoinTableData::current_chunk_shared, dsa_get_address(), InvalidDsaPointer, HashJoinTableData::log2_nbuckets, my_log2(), ParallelHashJoinState::nbuckets, HashJoinTableData::nbuckets, HashJoinTableData::parallel_state, ParallelHashJoinBatchAccessor::shared, and HashJoinTableData::shared.
Referenced by ExecParallelHashIncreaseNumBatches(), ExecParallelHashIncreaseNumBuckets(), ExecParallelHashJoinNewBatch(), and MultiExecParallelHash().
bool ExecParallelPrepHashTableForUnmatched | ( | HashJoinState * | hjstate | ) |
Definition at line 1990 of file nodeHash.c.
References Assert, BarrierArriveAndDetachExceptLast(), BarrierPhase(), ParallelHashJoinBatch::batch_barrier, HashJoinTableData::batches, HashJoinTableData::curbatch, ParallelHashJoinBatchAccessor::done, ExecHashTableDetachBatch(), ExecPrepHashTableForUnmatched(), HashJoinState::hj_HashTable, ParallelHashJoinBatchAccessor::inner_tuples, Max, HashJoinTableData::nbuckets, ParallelHashJoinBatchAccessor::outer_tuples, PHJ_BATCH_PROBE, PHJ_BATCH_SCAN, ParallelHashJoinBatchAccessor::shared, ParallelHashJoinBatch::size, ParallelHashJoinBatch::skip_unmatched, HashJoinTableData::spacePeak, and sts_end_parallel_scan().
Referenced by ExecHashJoinImpl().
bool ExecParallelScanHashBucket | ( | HashJoinState * | hjstate, |
ExprContext * | econtext | ||
) |
Definition at line 1918 of file nodeHash.c.
References ExprContext::ecxt_innertuple, ExecParallelHashFirstTuple(), ExecParallelHashNextTuple(), ExecQualAndReset(), ExecStoreMinimalTuple(), HashJoinState::hashclauses, HashJoinTupleData::hashvalue, HashJoinState::hj_CurBucketNo, HashJoinState::hj_CurHashValue, HashJoinState::hj_CurTuple, HashJoinState::hj_HashTable, HashJoinState::hj_HashTupleSlot, and HJTUPLE_MINTUPLE.
Referenced by ExecHashJoinImpl().
bool ExecParallelScanHashTableForUnmatched | ( | HashJoinState * | hjstate, |
ExprContext * | econtext | ||
) |
Definition at line 2129 of file nodeHash.c.
References CHECK_FOR_INTERRUPTS, ExprContext::ecxt_innertuple, ExecParallelHashFirstTuple(), ExecParallelHashNextTuple(), ExecStoreMinimalTuple(), HeapTupleHeaderHasMatch, HashJoinState::hj_CurBucketNo, HashJoinState::hj_CurTuple, HashJoinState::hj_HashTable, HashJoinState::hj_HashTupleSlot, HJTUPLE_MINTUPLE, HashJoinTableData::nbuckets, and ResetExprContext.
Referenced by ExecHashJoinImpl().
void ExecPrepHashTableForUnmatched | ( | HashJoinState * | hjstate | ) |
Definition at line 1969 of file nodeHash.c.
References HashJoinState::hj_CurBucketNo, HashJoinState::hj_CurSkewBucketNo, and HashJoinState::hj_CurTuple.
Referenced by ExecHashJoinImpl(), and ExecParallelPrepHashTableForUnmatched().
void ExecReScanHash | ( | HashState * | node | ) |
Definition at line 2246 of file nodeHash.c.
References ExecReScan(), outerPlan, and outerPlanState.
Referenced by ExecReScan().
bool ExecScanHashBucket | ( | HashJoinState * | hjstate, |
ExprContext * | econtext | ||
) |
Definition at line 1857 of file nodeHash.c.
References HashJoinTableData::buckets, ExprContext::ecxt_innertuple, ExecQualAndReset(), ExecStoreMinimalTuple(), HashJoinState::hashclauses, HashJoinTupleData::hashvalue, HashJoinState::hj_CurBucketNo, HashJoinState::hj_CurHashValue, HashJoinState::hj_CurSkewBucketNo, HashJoinState::hj_CurTuple, HashJoinState::hj_HashTable, HashJoinState::hj_HashTupleSlot, HJTUPLE_MINTUPLE, INVALID_SKEW_BUCKET_NO, HashJoinTupleData::next, HashJoinTableData::skewBucket, HashSkewBucket::tuples, HashJoinTupleData::unshared, and HashJoinTableData::unshared.
Referenced by ExecHashJoinImpl().
bool ExecScanHashTableForUnmatched | ( | HashJoinState * | hjstate, |
ExprContext * | econtext | ||
) |
Definition at line 2055 of file nodeHash.c.
References HashJoinTableData::buckets, CHECK_FOR_INTERRUPTS, ExprContext::ecxt_innertuple, ExecStoreMinimalTuple(), HeapTupleHeaderHasMatch, HashJoinState::hj_CurBucketNo, HashJoinState::hj_CurSkewBucketNo, HashJoinState::hj_CurTuple, HashJoinState::hj_HashTable, HashJoinState::hj_HashTupleSlot, HJTUPLE_MINTUPLE, j, HashJoinTableData::nbuckets, HashJoinTupleData::next, HashJoinTableData::nSkewBuckets, ResetExprContext, HashJoinTableData::skewBucket, HashJoinTableData::skewBucketNums, HashSkewBucket::tuples, HashJoinTupleData::unshared, and HashJoinTableData::unshared.
Referenced by ExecHashJoinImpl().
void ExecShutdownHash | ( | HashState * | node | ) |
Definition at line 2696 of file nodeHash.c.
References ExecHashAccumInstrumentation(), HashState::hashtable, HashState::hinstrument, PlanState::instrument, palloc0_object, and HashState::ps.
Referenced by ExecShutdownNode_walker().
Definition at line 105 of file nodeHash.c.
References HashState::hashtable, InstrStartNode(), InstrStopNode(), PlanState::instrument, MultiExecParallelHash(), MultiExecPrivateHash(), HashState::parallel_state, HashJoinTableData::partialTuples, and HashState::ps.
Referenced by MultiExecProcNode().