PostgreSQL Source Code  git master
hashjoin.h File Reference
#include "nodes/execnodes.h"
#include "port/atomics.h"
#include "storage/barrier.h"
#include "storage/buffile.h"
#include "storage/lwlock.h"
Include dependency graph for hashjoin.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  HashJoinTupleData
 
struct  HashSkewBucket
 
struct  HashMemoryChunkData
 
struct  ParallelHashJoinBatch
 
struct  ParallelHashJoinBatchAccessor
 
struct  ParallelHashJoinState
 
struct  HashJoinTableData
 

Macros

#define HJTUPLE_OVERHEAD   MAXALIGN(sizeof(HashJoinTupleData))
 
#define HJTUPLE_MINTUPLE(hjtup)   ((MinimalTuple) ((char *) (hjtup) + HJTUPLE_OVERHEAD))
 
#define SKEW_BUCKET_OVERHEAD   MAXALIGN(sizeof(HashSkewBucket))
 
#define INVALID_SKEW_BUCKET_NO   (-1)
 
#define SKEW_WORK_MEM_PERCENT   2
 
#define SKEW_MIN_OUTER_FRACTION   0.01
 
#define HASH_CHUNK_SIZE   (32 * 1024L)
 
#define HASH_CHUNK_HEADER_SIZE   MAXALIGN(sizeof(HashMemoryChunkData))
 
#define HASH_CHUNK_DATA(hc)   (((char *) (hc)) + HASH_CHUNK_HEADER_SIZE)
 
#define HASH_CHUNK_THRESHOLD   (HASH_CHUNK_SIZE / 4)
 
#define ParallelHashJoinBatchInner(batch)
 
#define ParallelHashJoinBatchOuter(batch, nparticipants)
 
#define EstimateParallelHashJoinBatch(hashtable)
 
#define NthParallelHashJoinBatch(base, n)
 
#define PHJ_BUILD_ELECTING   0
 
#define PHJ_BUILD_ALLOCATING   1
 
#define PHJ_BUILD_HASHING_INNER   2
 
#define PHJ_BUILD_HASHING_OUTER   3
 
#define PHJ_BUILD_DONE   4
 
#define PHJ_BATCH_ELECTING   0
 
#define PHJ_BATCH_ALLOCATING   1
 
#define PHJ_BATCH_LOADING   2
 
#define PHJ_BATCH_PROBING   3
 
#define PHJ_BATCH_DONE   4
 
#define PHJ_GROW_BATCHES_ELECTING   0
 
#define PHJ_GROW_BATCHES_ALLOCATING   1
 
#define PHJ_GROW_BATCHES_REPARTITIONING   2
 
#define PHJ_GROW_BATCHES_DECIDING   3
 
#define PHJ_GROW_BATCHES_FINISHING   4
 
#define PHJ_GROW_BATCHES_PHASE(n)   ((n) % 5) /* circular phases */
 
#define PHJ_GROW_BUCKETS_ELECTING   0
 
#define PHJ_GROW_BUCKETS_ALLOCATING   1
 
#define PHJ_GROW_BUCKETS_REINSERTING   2
 
#define PHJ_GROW_BUCKETS_PHASE(n)   ((n) % 3) /* circular phases */
 

Typedefs

typedef struct HashJoinTupleData HashJoinTupleData
 
typedef struct HashSkewBucket HashSkewBucket
 
typedef struct HashMemoryChunkData HashMemoryChunkData
 
typedef struct HashMemoryChunkDataHashMemoryChunk
 
typedef struct ParallelHashJoinBatch ParallelHashJoinBatch
 
typedef struct ParallelHashJoinBatchAccessor ParallelHashJoinBatchAccessor
 
typedef enum ParallelHashGrowth ParallelHashGrowth
 
typedef struct ParallelHashJoinState ParallelHashJoinState
 
typedef struct HashJoinTableData HashJoinTableData
 

Enumerations

enum  ParallelHashGrowth { PHJ_GROWTH_OK, PHJ_GROWTH_NEED_MORE_BUCKETS, PHJ_GROWTH_NEED_MORE_BATCHES, PHJ_GROWTH_DISABLED }
 

Macro Definition Documentation

◆ EstimateParallelHashJoinBatch

#define EstimateParallelHashJoinBatch (   hashtable)
Value:
MAXALIGN(sts_estimate((hashtable)->parallel_state->nparticipants)) * 2)
size_t sts_estimate(int participants)
#define MAXALIGN(LEN)
Definition: c.h:652

Definition at line 181 of file hashjoin.h.

Referenced by ExecParallelHashJoinSetUpBatches().

◆ HASH_CHUNK_DATA

◆ HASH_CHUNK_HEADER_SIZE

#define HASH_CHUNK_HEADER_SIZE   MAXALIGN(sizeof(HashMemoryChunkData))

◆ HASH_CHUNK_SIZE

#define HASH_CHUNK_SIZE   (32 * 1024L)

◆ HASH_CHUNK_THRESHOLD

#define HASH_CHUNK_THRESHOLD   (HASH_CHUNK_SIZE / 4)

Definition at line 143 of file hashjoin.h.

Referenced by dense_alloc(), and ExecParallelHashTupleAlloc().

◆ HJTUPLE_MINTUPLE

◆ HJTUPLE_OVERHEAD

◆ INVALID_SKEW_BUCKET_NO

#define INVALID_SKEW_BUCKET_NO   (-1)

◆ NthParallelHashJoinBatch

#define NthParallelHashJoinBatch (   base,
 
)
Value:
((char *) (base) + \
EstimateParallelHashJoinBatch(hashtable) * (n)))
#define EstimateParallelHashJoinBatch(hashtable)
Definition: hashjoin.h:181

Definition at line 186 of file hashjoin.h.

Referenced by ExecParallelHashEnsureBatchAccessors(), ExecParallelHashJoinSetUpBatches(), and ExecParallelHashRepartitionRest().

◆ ParallelHashJoinBatchInner

#define ParallelHashJoinBatchInner (   batch)

◆ ParallelHashJoinBatchOuter

#define ParallelHashJoinBatchOuter (   batch,
  nparticipants 
)
Value:
((char *) ParallelHashJoinBatchInner(batch) + \
MAXALIGN(sts_estimate(nparticipants))))
size_t sts_estimate(int participants)
#define ParallelHashJoinBatchInner(batch)
Definition: hashjoin.h:170

Definition at line 175 of file hashjoin.h.

Referenced by ExecParallelHashEnsureBatchAccessors(), and ExecParallelHashJoinSetUpBatches().

◆ PHJ_BATCH_ALLOCATING

#define PHJ_BATCH_ALLOCATING   1

Definition at line 265 of file hashjoin.h.

Referenced by ExecParallelHashJoinNewBatch().

◆ PHJ_BATCH_DONE

#define PHJ_BATCH_DONE   4

Definition at line 268 of file hashjoin.h.

Referenced by ExecHashTableDetachBatch(), and ExecParallelHashJoinNewBatch().

◆ PHJ_BATCH_ELECTING

#define PHJ_BATCH_ELECTING   0

Definition at line 264 of file hashjoin.h.

Referenced by ExecParallelHashJoinNewBatch().

◆ PHJ_BATCH_LOADING

#define PHJ_BATCH_LOADING   2

Definition at line 266 of file hashjoin.h.

Referenced by ExecParallelHashJoinNewBatch().

◆ PHJ_BATCH_PROBING

#define PHJ_BATCH_PROBING   3

Definition at line 267 of file hashjoin.h.

Referenced by ExecParallelHashJoinNewBatch(), and ExecParallelHashJoinSetUpBatches().

◆ PHJ_BUILD_ALLOCATING

#define PHJ_BUILD_ALLOCATING   1

Definition at line 258 of file hashjoin.h.

Referenced by MultiExecParallelHash().

◆ PHJ_BUILD_DONE

#define PHJ_BUILD_DONE   4

Definition at line 261 of file hashjoin.h.

Referenced by ExecHashJoinImpl(), and MultiExecParallelHash().

◆ PHJ_BUILD_ELECTING

#define PHJ_BUILD_ELECTING   0

Definition at line 257 of file hashjoin.h.

Referenced by ExecHashTableCreate().

◆ PHJ_BUILD_HASHING_INNER

◆ PHJ_BUILD_HASHING_OUTER

#define PHJ_BUILD_HASHING_OUTER   3

Definition at line 260 of file hashjoin.h.

Referenced by ExecHashJoinImpl(), and MultiExecParallelHash().

◆ PHJ_GROW_BATCHES_ALLOCATING

#define PHJ_GROW_BATCHES_ALLOCATING   1

Definition at line 272 of file hashjoin.h.

Referenced by ExecParallelHashIncreaseNumBatches().

◆ PHJ_GROW_BATCHES_DECIDING

#define PHJ_GROW_BATCHES_DECIDING   3

Definition at line 274 of file hashjoin.h.

Referenced by ExecParallelHashIncreaseNumBatches().

◆ PHJ_GROW_BATCHES_ELECTING

#define PHJ_GROW_BATCHES_ELECTING   0

Definition at line 271 of file hashjoin.h.

Referenced by ExecParallelHashIncreaseNumBatches(), and MultiExecParallelHash().

◆ PHJ_GROW_BATCHES_FINISHING

#define PHJ_GROW_BATCHES_FINISHING   4

Definition at line 275 of file hashjoin.h.

Referenced by ExecParallelHashIncreaseNumBatches().

◆ PHJ_GROW_BATCHES_PHASE

#define PHJ_GROW_BATCHES_PHASE (   n)    ((n) % 5) /* circular phases */

Definition at line 276 of file hashjoin.h.

Referenced by ExecParallelHashIncreaseNumBatches(), and MultiExecParallelHash().

◆ PHJ_GROW_BATCHES_REPARTITIONING

#define PHJ_GROW_BATCHES_REPARTITIONING   2

Definition at line 273 of file hashjoin.h.

Referenced by ExecParallelHashIncreaseNumBatches().

◆ PHJ_GROW_BUCKETS_ALLOCATING

#define PHJ_GROW_BUCKETS_ALLOCATING   1

Definition at line 280 of file hashjoin.h.

Referenced by ExecParallelHashIncreaseNumBuckets().

◆ PHJ_GROW_BUCKETS_ELECTING

#define PHJ_GROW_BUCKETS_ELECTING   0

Definition at line 279 of file hashjoin.h.

Referenced by ExecParallelHashIncreaseNumBuckets(), and MultiExecParallelHash().

◆ PHJ_GROW_BUCKETS_PHASE

#define PHJ_GROW_BUCKETS_PHASE (   n)    ((n) % 3) /* circular phases */

Definition at line 282 of file hashjoin.h.

Referenced by ExecParallelHashIncreaseNumBuckets(), and MultiExecParallelHash().

◆ PHJ_GROW_BUCKETS_REINSERTING

#define PHJ_GROW_BUCKETS_REINSERTING   2

Definition at line 281 of file hashjoin.h.

Referenced by ExecParallelHashIncreaseNumBuckets().

◆ SKEW_BUCKET_OVERHEAD

#define SKEW_BUCKET_OVERHEAD   MAXALIGN(sizeof(HashSkewBucket))

◆ SKEW_MIN_OUTER_FRACTION

#define SKEW_MIN_OUTER_FRACTION   0.01

Definition at line 111 of file hashjoin.h.

Referenced by ExecHashBuildSkewHash().

◆ SKEW_WORK_MEM_PERCENT

#define SKEW_WORK_MEM_PERCENT   2

Definition at line 110 of file hashjoin.h.

Referenced by ExecChooseHashTableSize(), and ExecHashTableCreate().

Typedef Documentation

◆ HashJoinTableData

◆ HashJoinTupleData

◆ HashMemoryChunk

Definition at line 137 of file hashjoin.h.

◆ HashMemoryChunkData

◆ HashSkewBucket

◆ ParallelHashGrowth

◆ ParallelHashJoinBatch

◆ ParallelHashJoinBatchAccessor

◆ ParallelHashJoinState

Enumeration Type Documentation

◆ ParallelHashGrowth

Enumerator
PHJ_GROWTH_OK 
PHJ_GROWTH_NEED_MORE_BUCKETS 
PHJ_GROWTH_NEED_MORE_BATCHES 
PHJ_GROWTH_DISABLED 

Definition at line 218 of file hashjoin.h.

219 {
220  /* The current dimensions are sufficient. */
222  /* The load factor is too high, so we need to add buckets. */
224  /* The memory budget would be exhausted, so we need to repartition. */
226  /* Repartitioning didn't help last time, so don't try to do that again. */
ParallelHashGrowth
Definition: hashjoin.h:218