1
0
mirror of https://github.com/postgres/postgres.git synced 2025-09-09 13:09:39 +03:00

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.
This commit is contained in:
Tom Lane
2005-01-28 19:36:33 +00:00
parent af5cd5ba92
commit a098f533d1
5 changed files with 141 additions and 71 deletions

View File

@@ -45,7 +45,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/executor/nodeAgg.c,v 1.126.4.1 2005/01/27 23:42:44 tgl Exp $
* $PostgreSQL: pgsql/src/backend/executor/nodeAgg.c,v 1.126.4.2 2005/01/28 19:35:56 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -604,6 +604,26 @@ build_hash_table(AggState *aggstate)
tmpmem);
}
/*
* 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.