aboutsummaryrefslogtreecommitdiff
path: root/src/backend/executor/nodeAgg.c
diff options
context:
space:
mode:
authorJeff Davis <jdavis@postgresql.org>2025-01-13 14:14:07 -0800
committerJeff Davis <jdavis@postgresql.org>2025-01-13 14:14:33 -0800
commitb4a07f532b40a64fb4714a3f7ab6063435411edb (patch)
tree0b46b6e5213ca51b3516e823af4c6864ae55d604 /src/backend/executor/nodeAgg.c
parentaf2317652d5daf8b382cc65936731c4a3c0aaa4c (diff)
downloadpostgresql-b4a07f532b40a64fb4714a3f7ab6063435411edb.tar.gz
postgresql-b4a07f532b40a64fb4714a3f7ab6063435411edb.zip
Revert "TupleHashTable: store additional data along with tuple."
This reverts commit e0ece2a981ee9068f50c4423e303836c2585eb02 due to performance regressions. Reported-by: David Rowley
Diffstat (limited to 'src/backend/executor/nodeAgg.c')
-rw-r--r--src/backend/executor/nodeAgg.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/backend/executor/nodeAgg.c b/src/backend/executor/nodeAgg.c
index 19640752967..3005b5c0e3b 100644
--- a/src/backend/executor/nodeAgg.c
+++ b/src/backend/executor/nodeAgg.c
@@ -1713,7 +1713,7 @@ hash_agg_entry_size(int numTrans, Size tupleWidth, Size transitionSpace)
transitionChunkSize = 0;
return
- TupleHashEntrySize() +
+ sizeof(TupleHashEntryData) +
tupleChunkSize +
pergroupChunkSize +
transitionChunkSize;
@@ -1954,7 +1954,7 @@ hash_agg_update_metrics(AggState *aggstate, bool from_tape, int npartitions)
if (aggstate->hash_ngroups_current > 0)
{
aggstate->hashentrysize =
- TupleHashEntrySize() +
+ sizeof(TupleHashEntryData) +
(hashkey_mem / (double) aggstate->hash_ngroups_current);
}
}
@@ -2055,7 +2055,11 @@ initialize_hash_entry(AggState *aggstate, TupleHashTable hashtable,
if (aggstate->numtrans == 0)
return;
- pergroup = (AggStatePerGroup) TupleHashEntryGetAdditional(entry);
+ pergroup = (AggStatePerGroup)
+ MemoryContextAlloc(hashtable->tablecxt,
+ sizeof(AggStatePerGroupData) * aggstate->numtrans);
+
+ entry->additional = pergroup;
/*
* Initialize aggregates for new tuple group, lookup_hash_entries()
@@ -2119,7 +2123,7 @@ lookup_hash_entries(AggState *aggstate)
{
if (isnew)
initialize_hash_entry(aggstate, hashtable, entry);
- pergroup[setno] = TupleHashEntryGetAdditional(entry);
+ pergroup[setno] = entry->additional;
}
else
{
@@ -2677,7 +2681,7 @@ agg_refill_hash_table(AggState *aggstate)
{
if (isnew)
initialize_hash_entry(aggstate, perhash->hashtable, entry);
- aggstate->hash_pergroup[batch->setno] = TupleHashEntryGetAdditional(entry);
+ aggstate->hash_pergroup[batch->setno] = entry->additional;
advance_aggregates(aggstate);
}
else
@@ -2769,7 +2773,7 @@ agg_retrieve_hash_table_in_memory(AggState *aggstate)
ExprContext *econtext;
AggStatePerAgg peragg;
AggStatePerGroup pergroup;
- TupleHashEntry entry;
+ TupleHashEntryData *entry;
TupleTableSlot *firstSlot;
TupleTableSlot *result;
AggStatePerHash perhash;
@@ -2841,7 +2845,7 @@ agg_retrieve_hash_table_in_memory(AggState *aggstate)
* Transform representative tuple back into one with the right
* columns.
*/
- ExecStoreMinimalTuple(TupleHashEntryGetTuple(entry), hashslot, false);
+ ExecStoreMinimalTuple(entry->firstTuple, hashslot, false);
slot_getallattrs(hashslot);
ExecClearTuple(firstSlot);
@@ -2857,7 +2861,7 @@ agg_retrieve_hash_table_in_memory(AggState *aggstate)
}
ExecStoreVirtualTuple(firstSlot);
- pergroup = (AggStatePerGroup) TupleHashEntryGetAdditional(entry);
+ pergroup = (AggStatePerGroup) entry->additional;
/*
* Use the representative input tuple for any references to