mirror of
https://github.com/postgres/postgres.git
synced 2025-08-19 23:22:23 +03:00
Remove 'additional' pointer from TupleHashEntryData.
Reduces memory required for hash aggregation by avoiding an allocation and a pointer in the TupleHashEntryData structure. That structure is used for all buckets, whether occupied or not, so the savings is substantial. Discussion: https://postgr.es/m/AApHDvpN4v3t_sdz4dvrv1Fx_ZPw=twSnxuTEytRYP7LFz5K9A@mail.gmail.com Reviewed-by: David Rowley <dgrowleyml@gmail.com>
This commit is contained in:
@@ -485,11 +485,18 @@ LookupTupleHashEntry_internal(TupleHashTable hashtable, TupleTableSlot *slot,
|
||||
|
||||
MemoryContextSwitchTo(hashtable->tablecxt);
|
||||
|
||||
entry->firstTuple = ExecCopySlotMinimalTuple(slot);
|
||||
if (hashtable->additionalsize > 0)
|
||||
entry->additional = palloc0(hashtable->additionalsize);
|
||||
else
|
||||
entry->additional = NULL;
|
||||
/*
|
||||
* Copy the first tuple into the table context, and request
|
||||
* additionalsize extra bytes before the allocation.
|
||||
*
|
||||
* The caller can get a pointer to the additional data with
|
||||
* TupleHashEntryGetAdditional(), and store arbitrary data there.
|
||||
* Placing both the tuple and additional data in the same
|
||||
* allocation avoids the need to store an extra pointer in
|
||||
* TupleHashEntryData or allocate an additional chunk.
|
||||
*/
|
||||
entry->firstTuple = ExecCopySlotMinimalTupleExtra(slot,
|
||||
hashtable->additionalsize);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
Reference in New Issue
Block a user