mirror of
https://github.com/postgres/postgres.git
synced 2025-07-05 07:21:24 +03:00
HashAgg: before spilling tuples, set unneeded columns to NULL.
This is a replacement for 4cad2534
. Instead of projecting all tuples
going into a HashAgg, only remove unnecessary attributes when actually
spilling. This avoids the regression for the in-memory case.
Discussion: https://postgr.es/m/a2fb7dfeb4f50aa0a123e42151ee3013933cb802.camel%40j-davis.com
Backpatch-through: 13
This commit is contained in:
@ -2169,6 +2169,9 @@ typedef struct AggState
|
||||
int current_set; /* The current grouping set being evaluated */
|
||||
Bitmapset *grouped_cols; /* grouped cols in current projection */
|
||||
List *all_grouped_cols; /* list of all grouped cols in DESC order */
|
||||
Bitmapset *colnos_needed; /* all columns needed from the outer plan */
|
||||
int max_colno_needed; /* highest colno needed from outer plan */
|
||||
bool all_cols_needed; /* are all cols from outer plan needed? */
|
||||
/* These fields are for grouping set phase data */
|
||||
int maxsets; /* The max number of sets in any phase */
|
||||
AggStatePerPhase phases; /* array of all phases */
|
||||
@ -2186,7 +2189,8 @@ typedef struct AggState
|
||||
struct HashTapeInfo *hash_tapeinfo; /* metadata for spill tapes */
|
||||
struct HashAggSpill *hash_spills; /* HashAggSpill for each grouping set,
|
||||
* exists only during first pass */
|
||||
TupleTableSlot *hash_spill_slot; /* slot for reading from spill files */
|
||||
TupleTableSlot *hash_spill_rslot; /* for reading spill files */
|
||||
TupleTableSlot *hash_spill_wslot; /* for writing spill files */
|
||||
List *hash_batches; /* hash batches remaining to be processed */
|
||||
bool hash_ever_spilled; /* ever spilled during this execution? */
|
||||
bool hash_spill_mode; /* we hit a limit during the current batch
|
||||
@ -2207,7 +2211,7 @@ typedef struct AggState
|
||||
* per-group pointers */
|
||||
|
||||
/* support for evaluation of agg input expressions: */
|
||||
#define FIELDNO_AGGSTATE_ALL_PERGROUPS 49
|
||||
#define FIELDNO_AGGSTATE_ALL_PERGROUPS 53
|
||||
AggStatePerGroup *all_pergroups; /* array of first ->pergroups, than
|
||||
* ->hash_pergroup */
|
||||
ProjectionInfo *combinedproj; /* projection machinery */
|
||||
|
Reference in New Issue
Block a user