diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2005-01-28 19:34:28 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2005-01-28 19:34:28 +0000 |
commit | 0bf2587df46f3b554d62f7628d1d474bda7ddfc5 (patch) | |
tree | 92f670d4d386d72eab646685648d6cf3f4a546eb /src/backend/executor/nodeAgg.c | |
parent | c3a4e22e826ca2cd2f1e1b6d6dd4ae953b6755f1 (diff) | |
download | postgresql-0bf2587df46f3b554d62f7628d1d474bda7ddfc5.tar.gz postgresql-0bf2587df46f3b554d62f7628d1d474bda7ddfc5.zip |
Improve planner's estimation of the space needed for HashAgg plans:
look at the actual aggregate transition datatypes and the actual overhead
needed by nodeAgg.c, instead of using pessimistic round numbers.
Per a discussion with Michael Tiemann.
Diffstat (limited to 'src/backend/executor/nodeAgg.c')
-rw-r--r-- | src/backend/executor/nodeAgg.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/backend/executor/nodeAgg.c b/src/backend/executor/nodeAgg.c index 19d246914ce..63a687e9869 100644 --- a/src/backend/executor/nodeAgg.c +++ b/src/backend/executor/nodeAgg.c @@ -45,7 +45,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/executor/nodeAgg.c,v 1.127 2005/01/27 23:42:18 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/executor/nodeAgg.c,v 1.128 2005/01/28 19:33:56 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -605,6 +605,26 @@ build_hash_table(AggState *aggstate) } /* + * Estimate per-hash-table-entry overhead for the planner. + * + * Note that the estimate does not include space for pass-by-reference + * transition data values. + */ +Size +hash_agg_entry_size(int numAggs) +{ + Size entrysize; + + /* This must match build_hash_table */ + entrysize = sizeof(AggHashEntryData) + + (numAggs - 1) *sizeof(AggStatePerGroupData); + /* Account for hashtable overhead */ + entrysize += 2 * sizeof(void *); + entrysize = MAXALIGN(entrysize); + return entrysize; +} + +/* * Find or create a hashtable entry for the tuple group containing the * given tuple. * |