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_HASH_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_ELECT   0
 
#define PHJ_BUILD_ALLOCATE   1
 
#define PHJ_BUILD_HASH_INNER   2
 
#define PHJ_BUILD_HASH_OUTER   3
 
#define PHJ_BUILD_RUN   4
 
#define PHJ_BUILD_FREE   5
 
#define PHJ_BATCH_ELECT   0
 
#define PHJ_BATCH_ALLOCATE   1
 
#define PHJ_BATCH_LOAD   2
 
#define PHJ_BATCH_PROBE   3
 
#define PHJ_BATCH_SCAN   4
 
#define PHJ_BATCH_FREE   5
 
#define PHJ_GROW_BATCHES_ELECT   0
 
#define PHJ_GROW_BATCHES_REALLOCATE   1
 
#define PHJ_GROW_BATCHES_REPARTITION   2
 
#define PHJ_GROW_BATCHES_DECIDE   3
 
#define PHJ_GROW_BATCHES_FINISH   4
 
#define PHJ_GROW_BATCHES_PHASE(n)   ((n) % 5) /* circular phases */
 
#define PHJ_GROW_BUCKETS_ELECT   0
 
#define PHJ_GROW_BUCKETS_REALLOCATE   1
 
#define PHJ_GROW_BUCKETS_REINSERT   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)
#define MAXALIGN(LEN)
Definition: c.h:802
size_t sts_estimate(int participants)

Definition at line 193 of file hashjoin.h.

◆ HASH_CHUNK_DATA

#define HASH_CHUNK_DATA (   hc)    (((char *) (hc)) + HASH_CHUNK_HEADER_SIZE)

Definition at line 152 of file hashjoin.h.

◆ HASH_CHUNK_HEADER_SIZE

#define HASH_CHUNK_HEADER_SIZE   MAXALIGN(sizeof(HashMemoryChunkData))

Definition at line 151 of file hashjoin.h.

◆ HASH_CHUNK_SIZE

#define HASH_CHUNK_SIZE   (32 * 1024L)

Definition at line 150 of file hashjoin.h.

◆ HASH_CHUNK_THRESHOLD

#define HASH_CHUNK_THRESHOLD   (HASH_CHUNK_SIZE / 4)

Definition at line 154 of file hashjoin.h.

◆ HJTUPLE_MINTUPLE

#define HJTUPLE_MINTUPLE (   hjtup)     ((MinimalTuple) ((char *) (hjtup) + HJTUPLE_OVERHEAD))

Definition at line 91 of file hashjoin.h.

◆ HJTUPLE_OVERHEAD

#define HJTUPLE_OVERHEAD   MAXALIGN(sizeof(HashJoinTupleData))

Definition at line 90 of file hashjoin.h.

◆ INVALID_SKEW_BUCKET_NO

#define INVALID_SKEW_BUCKET_NO   (-1)

Definition at line 120 of file hashjoin.h.

◆ NthParallelHashJoinBatch

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

Definition at line 198 of file hashjoin.h.

◆ ParallelHashJoinBatchInner

#define ParallelHashJoinBatchInner (   batch)
Value:
((char *) (batch) + MAXALIGN(sizeof(ParallelHashJoinBatch))))

Definition at line 182 of file hashjoin.h.

◆ ParallelHashJoinBatchOuter

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

Definition at line 187 of file hashjoin.h.

◆ PHJ_BATCH_ALLOCATE

#define PHJ_BATCH_ALLOCATE   1

Definition at line 278 of file hashjoin.h.

◆ PHJ_BATCH_ELECT

#define PHJ_BATCH_ELECT   0

Definition at line 277 of file hashjoin.h.

◆ PHJ_BATCH_FREE

#define PHJ_BATCH_FREE   5

Definition at line 282 of file hashjoin.h.

◆ PHJ_BATCH_LOAD

#define PHJ_BATCH_LOAD   2

Definition at line 279 of file hashjoin.h.

◆ PHJ_BATCH_PROBE

#define PHJ_BATCH_PROBE   3

Definition at line 280 of file hashjoin.h.

◆ PHJ_BATCH_SCAN

#define PHJ_BATCH_SCAN   4

Definition at line 281 of file hashjoin.h.

◆ PHJ_BUILD_ALLOCATE

#define PHJ_BUILD_ALLOCATE   1

Definition at line 270 of file hashjoin.h.

◆ PHJ_BUILD_ELECT

#define PHJ_BUILD_ELECT   0

Definition at line 269 of file hashjoin.h.

◆ PHJ_BUILD_FREE

#define PHJ_BUILD_FREE   5

Definition at line 274 of file hashjoin.h.

◆ PHJ_BUILD_HASH_INNER

#define PHJ_BUILD_HASH_INNER   2

Definition at line 271 of file hashjoin.h.

◆ PHJ_BUILD_HASH_OUTER

#define PHJ_BUILD_HASH_OUTER   3

Definition at line 272 of file hashjoin.h.

◆ PHJ_BUILD_RUN

#define PHJ_BUILD_RUN   4

Definition at line 273 of file hashjoin.h.

◆ PHJ_GROW_BATCHES_DECIDE

#define PHJ_GROW_BATCHES_DECIDE   3

Definition at line 288 of file hashjoin.h.

◆ PHJ_GROW_BATCHES_ELECT

#define PHJ_GROW_BATCHES_ELECT   0

Definition at line 285 of file hashjoin.h.

◆ PHJ_GROW_BATCHES_FINISH

#define PHJ_GROW_BATCHES_FINISH   4

Definition at line 289 of file hashjoin.h.

◆ PHJ_GROW_BATCHES_PHASE

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

Definition at line 290 of file hashjoin.h.

◆ PHJ_GROW_BATCHES_REALLOCATE

#define PHJ_GROW_BATCHES_REALLOCATE   1

Definition at line 286 of file hashjoin.h.

◆ PHJ_GROW_BATCHES_REPARTITION

#define PHJ_GROW_BATCHES_REPARTITION   2

Definition at line 287 of file hashjoin.h.

◆ PHJ_GROW_BUCKETS_ELECT

#define PHJ_GROW_BUCKETS_ELECT   0

Definition at line 293 of file hashjoin.h.

◆ PHJ_GROW_BUCKETS_PHASE

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

Definition at line 296 of file hashjoin.h.

◆ PHJ_GROW_BUCKETS_REALLOCATE

#define PHJ_GROW_BUCKETS_REALLOCATE   1

Definition at line 294 of file hashjoin.h.

◆ PHJ_GROW_BUCKETS_REINSERT

#define PHJ_GROW_BUCKETS_REINSERT   2

Definition at line 295 of file hashjoin.h.

◆ SKEW_BUCKET_OVERHEAD

#define SKEW_BUCKET_OVERHEAD   MAXALIGN(sizeof(HashSkewBucket))

Definition at line 119 of file hashjoin.h.

◆ SKEW_HASH_MEM_PERCENT

#define SKEW_HASH_MEM_PERCENT   2

Definition at line 121 of file hashjoin.h.

◆ SKEW_MIN_OUTER_FRACTION

#define SKEW_MIN_OUTER_FRACTION   0.01

Definition at line 122 of file hashjoin.h.

Typedef Documentation

◆ HashJoinTableData

◆ HashJoinTupleData

◆ HashMemoryChunk

Definition at line 148 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 230 of file hashjoin.h.

231 {
232  /* The current dimensions are sufficient. */
234  /* The load factor is too high, so we need to add buckets. */
236  /* The memory budget would be exhausted, so we need to repartition. */
238  /* Repartitioning didn't help last time, so don't try to do that again. */
ParallelHashGrowth
Definition: hashjoin.h:231
@ PHJ_GROWTH_NEED_MORE_BUCKETS
Definition: hashjoin.h:235
@ PHJ_GROWTH_OK
Definition: hashjoin.h:233
@ PHJ_GROWTH_NEED_MORE_BATCHES
Definition: hashjoin.h:237
@ PHJ_GROWTH_DISABLED
Definition: hashjoin.h:239