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

Commit0588ee6

Browse files
committed
Include chunk overhead in hash table entry size estimate.
Don't try to be precise about it, just use a constant 16 bytes ofchunk overhead. Being smarter would require knowing the memory contextwhere the chunk will be allocated, which is not known by all callers.Discussion:https://postgr.es/m/20200325220936.il3ni2fj2j2b45y5@alap3.anarazel.de
1 parent3e0d80f commit0588ee6

File tree

2 files changed

+31
-7
lines changed

2 files changed

+31
-7
lines changed

‎src/backend/executor/nodeAgg.c

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,12 @@
297297
/* minimum number of initial hash table buckets */
298298
#defineHASHAGG_MIN_BUCKETS 256
299299

300+
/*
301+
* Estimate chunk overhead as a constant 16 bytes. XXX: should this be
302+
* improved?
303+
*/
304+
#defineCHUNKHDRSZ 16
305+
300306
/*
301307
* Track all tapes needed for a HashAgg that spills. We don't know the maximum
302308
* number of tapes needed at the start of the algorithm (because it can
@@ -1639,14 +1645,32 @@ find_hash_columns(AggState *aggstate)
16391645
* Estimate per-hash-table-entry overhead.
16401646
*/
16411647
Size
1642-
hash_agg_entry_size(intnumAggs,SizetupleWidth,SizetransitionSpace)
1648+
hash_agg_entry_size(intnumTrans,SizetupleWidth,SizetransitionSpace)
16431649
{
1650+
SizetupleChunkSize;
1651+
SizepergroupChunkSize;
1652+
SizetransitionChunkSize;
1653+
SizetupleSize= (MAXALIGN(SizeofMinimalTupleHeader)+
1654+
tupleWidth);
1655+
SizepergroupSize=numTrans*sizeof(AggStatePerGroupData);
1656+
1657+
tupleChunkSize=CHUNKHDRSZ+tupleSize;
1658+
1659+
if (pergroupSize>0)
1660+
pergroupChunkSize=CHUNKHDRSZ+pergroupSize;
1661+
else
1662+
pergroupChunkSize=0;
1663+
1664+
if (transitionSpace>0)
1665+
transitionChunkSize=CHUNKHDRSZ+transitionSpace;
1666+
else
1667+
transitionChunkSize=0;
1668+
16441669
return
1645-
MAXALIGN(SizeofMinimalTupleHeader)+
1646-
MAXALIGN(tupleWidth)+
1647-
MAXALIGN(sizeof(TupleHashEntryData)+
1648-
numAggs*sizeof(AggStatePerGroupData))+
1649-
transitionSpace;
1670+
sizeof(TupleHashEntryData)+
1671+
tupleChunkSize+
1672+
pergroupChunkSize+
1673+
transitionChunkSize;
16501674
}
16511675

16521676
/*

‎src/include/executor/nodeAgg.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ extern AggState *ExecInitAgg(Agg *node, EState *estate, int eflags);
314314
externvoidExecEndAgg(AggState*node);
315315
externvoidExecReScanAgg(AggState*node);
316316

317-
externSizehash_agg_entry_size(intnumAggs,SizetupleWidth,
317+
externSizehash_agg_entry_size(intnumTrans,SizetupleWidth,
318318
SizetransitionSpace);
319319
externvoidhash_agg_set_limits(doublehashentrysize,uint64input_groups,
320320
intused_bits,Size*mem_limit,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp