diff options
author | Jeff Davis <jdavis@postgresql.org> | 2020-03-18 15:42:02 -0700 |
---|---|---|
committer | Jeff Davis <jdavis@postgresql.org> | 2020-03-18 15:42:02 -0700 |
commit | 1f39bce021540fde00990af55b4432c55ef4b3c7 (patch) | |
tree | c2403fb61234d93408b23350a82ad429b3625af3 /src/include/executor | |
parent | e00912e11a9ec2d29274ed8a6465e81385906dc2 (diff) | |
download | postgresql-1f39bce021540fde00990af55b4432c55ef4b3c7.tar.gz postgresql-1f39bce021540fde00990af55b4432c55ef4b3c7.zip |
Disk-based Hash Aggregation.
While performing hash aggregation, track memory usage when adding new
groups to a hash table. If the memory usage exceeds work_mem, enter
"spill mode".
In spill mode, new groups are not created in the hash table(s), but
existing groups continue to be advanced if input tuples match. Tuples
that would cause a new group to be created are instead spilled to a
logical tape to be processed later.
The tuples are spilled in a partitioned fashion. When all tuples from
the outer plan are processed (either by advancing the group or
spilling the tuple), finalize and emit the groups from the hash
table. Then, create new batches of work from the spilled partitions,
and select one of the saved batches and process it (possibly spilling
recursively).
Author: Jeff Davis
Reviewed-by: Tomas Vondra, Adam Lee, Justin Pryzby, Taylor Vesely, Melanie Plageman
Discussion: https://postgr.es/m/507ac540ec7c20136364b5272acbcd4574aa76ef.camel@j-davis.com
Diffstat (limited to 'src/include/executor')
-rw-r--r-- | src/include/executor/nodeAgg.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/include/executor/nodeAgg.h b/src/include/executor/nodeAgg.h index 264916f9a92..a5b8a004d1e 100644 --- a/src/include/executor/nodeAgg.h +++ b/src/include/executor/nodeAgg.h @@ -280,6 +280,11 @@ typedef struct AggStatePerPhaseData Sort *sortnode; /* Sort node for input ordering for phase */ ExprState *evaltrans; /* evaluation of transition functions */ + + /* cached variants of the compiled expression */ + ExprState *evaltrans_cache + [2] /* 0: outerops; 1: TTSOpsMinimalTuple */ + [2]; /* 0: no NULL check; 1: with NULL check */ } AggStatePerPhaseData; /* @@ -311,5 +316,8 @@ extern void ExecReScanAgg(AggState *node); extern Size hash_agg_entry_size(int numAggs, Size tupleWidth, Size transitionSpace); +extern void hash_agg_set_limits(double hashentrysize, uint64 input_groups, + int used_bits, Size *mem_limit, + uint64 *ngroups_limit, int *num_partitions); #endif /* NODEAGG_H */ |