aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2010-08-14 15:47:30 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2010-08-14 15:47:30 +0000
commit286fa734712f3d034ce402d712ba7291c1f64bac (patch)
tree019d81d7a3b7ee4e5605b79d2fccc16f2ce0c683 /src
parentdd56a9d6ededebc25e8f57f9d3a58e1b94f42a81 (diff)
downloadpostgresql-286fa734712f3d034ce402d712ba7291c1f64bac.tar.gz
postgresql-286fa734712f3d034ce402d712ba7291c1f64bac.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/backend/optimizer/util/clauses.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/backend/optimizer/util/clauses.c b/src/backend/optimizer/util/clauses.c
index 5f6c08c0134..f6ec7a64d54 100644
--- a/src/backend/optimizer/util/clauses.c
+++ b/src/backend/optimizer/util/clauses.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/optimizer/util/clauses.c,v 1.277.2.2 2010/03/19 22:54:49 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/optimizer/util/clauses.c,v 1.277.2.3 2010/08/14 15:47:30 tgl Exp $
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
@@ -542,6 +542,18 @@ count_agg_clauses_walker(Node *node, AggClauseCounts *counts)
counts->transitionSpace += avgwidth + 2 * sizeof(void *);
}
+ else if (aggtranstype == INTERNALOID)
+ {
+ /*
+ * INTERNAL transition type is a special case: although INTERNAL
+ * is pass-by-value, it's almost certainly being used as a pointer
+ * to some large data structure. We assume usage of
+ * ALLOCSET_DEFAULT_INITSIZE, which is a good guess if the data is
+ * being kept in a private memory context, as is done by
+ * array_agg() for instance.
+ */
+ counts->transitionSpace += ALLOCSET_DEFAULT_INITSIZE;
+ }
/*
* Complain if the aggregate's arguments contain any aggregates;