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

Commit7d4395d

Browse files
committed
Refactor hash_agg_entry_size().
Consolidate the calculations for hash table size estimation. This willhelp with upcoming Hash Aggregation work that will add additional callsites.
1 parentc02fdc9 commit7d4395d

File tree

4 files changed

+14
-33
lines changed

4 files changed

+14
-33
lines changed

‎src/backend/executor/nodeAgg.c

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1422,24 +1422,17 @@ find_hash_columns(AggState *aggstate)
14221422
}
14231423

14241424
/*
1425-
* Estimate per-hash-table-entry overhead for the planner.
1426-
*
1427-
* Note that the estimate does not include space for pass-by-reference
1428-
* transition data values, nor for the representative tuple of each group.
1429-
* Nor does this account of the target fill-factor and growth policy of the
1430-
* hash table.
1425+
* Estimate per-hash-table-entry overhead.
14311426
*/
14321427
Size
1433-
hash_agg_entry_size(intnumAggs)
1428+
hash_agg_entry_size(intnumAggs,SizetupleWidth,SizetransitionSpace)
14341429
{
1435-
Sizeentrysize;
1436-
1437-
/* This must match build_hash_table */
1438-
entrysize=sizeof(TupleHashEntryData)+
1439-
numAggs*sizeof(AggStatePerGroupData);
1440-
entrysize=MAXALIGN(entrysize);
1441-
1442-
returnentrysize;
1430+
return
1431+
MAXALIGN(SizeofMinimalTupleHeader)+
1432+
MAXALIGN(tupleWidth)+
1433+
MAXALIGN(sizeof(TupleHashEntryData)+
1434+
numAggs*sizeof(AggStatePerGroupData))+
1435+
transitionSpace;
14431436
}
14441437

14451438
/*

‎src/backend/optimizer/plan/planner.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4867,13 +4867,8 @@ create_distinct_paths(PlannerInfo *root,
48674867
allow_hash= false;/* policy-based decision not to hash */
48684868
else
48694869
{
4870-
Sizehashentrysize;
4871-
4872-
/* Estimate per-hash-entry space at tuple width... */
4873-
hashentrysize=MAXALIGN(cheapest_input_path->pathtarget->width)+
4874-
MAXALIGN(SizeofMinimalTupleHeader);
4875-
/* plus the per-hash-entry overhead */
4876-
hashentrysize+=hash_agg_entry_size(0);
4870+
Sizehashentrysize=hash_agg_entry_size(
4871+
0,cheapest_input_path->pathtarget->width,0);
48774872

48784873
/* Allow hashing only if hashtable is predicted to fit in work_mem */
48794874
allow_hash= (hashentrysize*numDistinctRows <=work_mem*1024L);

‎src/backend/utils/adt/selfuncs.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3526,16 +3526,8 @@ double
35263526
estimate_hashagg_tablesize(Path*path,constAggClauseCosts*agg_costs,
35273527
doubledNumGroups)
35283528
{
3529-
Sizehashentrysize;
3530-
3531-
/* Estimate per-hash-entry space at tuple width... */
3532-
hashentrysize=MAXALIGN(path->pathtarget->width)+
3533-
MAXALIGN(SizeofMinimalTupleHeader);
3534-
3535-
/* plus space for pass-by-ref transition values... */
3536-
hashentrysize+=agg_costs->transitionSpace;
3537-
/* plus the per-hash-entry overhead */
3538-
hashentrysize+=hash_agg_entry_size(agg_costs->numAggs);
3529+
Sizehashentrysize=hash_agg_entry_size(
3530+
agg_costs->numAggs,path->pathtarget->width,agg_costs->transitionSpace);
35393531

35403532
/*
35413533
* Note that this disregards the effect of fill-factor and growth policy

‎src/include/executor/nodeAgg.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,7 @@ extern AggState *ExecInitAgg(Agg *node, EState *estate, int eflags);
309309
externvoidExecEndAgg(AggState*node);
310310
externvoidExecReScanAgg(AggState*node);
311311

312-
externSizehash_agg_entry_size(intnumAggs);
312+
externSizehash_agg_entry_size(intnumAggs,SizetupleWidth,
313+
SizetransitionSpace);
313314

314315
#endif/* NODEAGG_H */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp