Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit626df47

Browse files
committed
Remove 'additional' pointer from TupleHashEntryData.
Reduces memory required for hash aggregation by avoiding an allocationand a pointer in the TupleHashEntryData structure. That structure isused for all buckets, whether occupied or not, so the savings issubstantial.Discussion:https://postgr.es/m/AApHDvpN4v3t_sdz4dvrv1Fx_ZPw=twSnxuTEytRYP7LFz5K9A@mail.gmail.comReviewed-by: David Rowley <dgrowleyml@gmail.com>
1 parenta0942f4 commit626df47

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

‎src/backend/executor/execGrouping.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -485,11 +485,18 @@ LookupTupleHashEntry_internal(TupleHashTable hashtable, TupleTableSlot *slot,
485485

486486
MemoryContextSwitchTo(hashtable->tablecxt);
487487

488-
entry->firstTuple=ExecCopySlotMinimalTuple(slot);
489-
if (hashtable->additionalsize>0)
490-
entry->additional=palloc0(hashtable->additionalsize);
491-
else
492-
entry->additional=NULL;
488+
/*
489+
* Copy the first tuple into the table context, and request
490+
* additionalsize extra bytes before the allocation.
491+
*
492+
* The caller can get a pointer to the additional data with
493+
* TupleHashEntryGetAdditional(), and store arbitrary data there.
494+
* Placing both the tuple and additional data in the same
495+
* allocation avoids the need to store an extra pointer in
496+
* TupleHashEntryData or allocate an additional chunk.
497+
*/
498+
entry->firstTuple=ExecCopySlotMinimalTupleExtra(slot,
499+
hashtable->additionalsize);
493500
}
494501
}
495502
else

‎src/include/executor/executor.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,10 @@ TupleHashEntryGetTuple(TupleHashEntry entry)
188188
staticinlinevoid*
189189
TupleHashEntryGetAdditional(TupleHashTablehashtable,TupleHashEntryentry)
190190
{
191-
returnentry->additional;
191+
if (hashtable->additionalsize>0)
192+
return (char*)entry->firstTuple-hashtable->additionalsize;
193+
else
194+
returnNULL;
192195
}
193196
#endif
194197

‎src/include/nodes/execnodes.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -840,7 +840,6 @@ typedef struct TupleHashTableData *TupleHashTable;
840840
typedefstructTupleHashEntryData
841841
{
842842
MinimalTuplefirstTuple;/* copy of first tuple in this group */
843-
void*additional;/* user data */
844843
uint32status;/* hash status */
845844
uint32hash;/* hash value (cached) */
846845
}TupleHashEntryData;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp