Skip to content

Commit 22d9ddb

Browse files
committed
Fix planner to make a reasonable assumption about the amount of memory space
used by array_agg(), string_agg(), and similar aggregate functions that use "internal" as their transition datatype. The previous coding thought this took *no* extra space, since "internal" is pass-by-value; but actually these aggregates typically consume a great deal of space. Per bug #5608 from Itagaki Takahiro, and fix suggestion from Hitoshi Harada. Back-patch to 8.4, where array_agg was introduced.
1 parent 41b810f commit 22d9ddb

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/backend/optimizer/util/clauses.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/optimizer/util/clauses.c,v 1.287 2010/03/19 22:54:41 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/optimizer/util/clauses.c,v 1.288 2010/08/14 15:47:13 tgl Exp $
1212
*
1313
* HISTORY
1414
* AUTHOR DATE MAJOR EVENT
@@ -549,6 +549,18 @@ count_agg_clauses_walker(Node *node, AggClauseCounts *counts)
549549

550550
counts->transitionSpace += avgwidth + 2 * sizeof(void *);
551551
}
552+
else if (aggtranstype == INTERNALOID)
553+
{
554+
/*
555+
* INTERNAL transition type is a special case: although INTERNAL
556+
* is pass-by-value, it's almost certainly being used as a pointer
557+
* to some large data structure. We assume usage of
558+
* ALLOCSET_DEFAULT_INITSIZE, which is a good guess if the data is
559+
* being kept in a private memory context, as is done by
560+
* array_agg() for instance.
561+
*/
562+
counts->transitionSpace += ALLOCSET_DEFAULT_INITSIZE;
563+
}
552564

553565
/*
554566
* Complain if the aggregate's arguments contain any aggregates;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy