aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2006-06-28 20:04:38 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2006-06-28 20:04:38 +0000
commit1c1ecd5124068a45fdecc0dcc4ba2581c15acf9f (patch)
treec7ecc0e07e153f32c35c4450e018b73c8570c72a /src
parent485375a1c9270fb3eefe4b9391dd976e563c2c1c (diff)
downloadpostgresql-1c1ecd5124068a45fdecc0dcc4ba2581c15acf9f.tar.gz
postgresql-1c1ecd5124068a45fdecc0dcc4ba2581c15acf9f.zip
Improve planner estimates for size of tuple hash tables.
Diffstat (limited to 'src')
-rw-r--r--src/backend/optimizer/plan/planner.c4
-rw-r--r--src/backend/optimizer/plan/subselect.c10
2 files changed, 8 insertions, 6 deletions
diff --git a/src/backend/optimizer/plan/planner.c b/src/backend/optimizer/plan/planner.c
index ea6a052918e..da1cadcd0db 100644
--- a/src/backend/optimizer/plan/planner.c
+++ b/src/backend/optimizer/plan/planner.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/optimizer/plan/planner.c,v 1.199 2006/03/05 15:58:29 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/optimizer/plan/planner.c,v 1.200 2006/06/28 20:04:38 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1298,7 +1298,7 @@ choose_hashed_grouping(PlannerInfo *root, double tuple_fraction,
}
/* Estimate per-hash-entry space at tuple width... */
- hashentrysize = cheapest_path_width;
+ hashentrysize = MAXALIGN(cheapest_path_width) + MAXALIGN(sizeof(MinimalTupleData));
/* plus space for pass-by-ref transition values... */
hashentrysize += agg_counts->transitionSpace;
/* plus the per-hash-entry overhead */
diff --git a/src/backend/optimizer/plan/subselect.c b/src/backend/optimizer/plan/subselect.c
index 1b5533cded4..c1304042a1d 100644
--- a/src/backend/optimizer/plan/subselect.c
+++ b/src/backend/optimizer/plan/subselect.c
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/optimizer/plan/subselect.c,v 1.107 2006/05/03 00:24:56 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/optimizer/plan/subselect.c,v 1.108 2006/06/28 20:04:38 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -585,11 +585,13 @@ subplan_is_hashable(SubLink *slink, SubPlan *node)
return false;
/*
- * The estimated size of the subquery result must fit in work_mem. (XXX
- * what about hashtable overhead?)
+ * The estimated size of the subquery result must fit in work_mem.
+ * (Note: we use sizeof(HeapTupleHeaderData) here even though the tuples
+ * will actually be stored as MinimalTuples; this provides some fudge
+ * factor for hashtable overhead.)
*/
subquery_size = node->plan->plan_rows *
- (MAXALIGN(node->plan->plan_width) + MAXALIGN(sizeof(HeapTupleData)));
+ (MAXALIGN(node->plan->plan_width) + MAXALIGN(sizeof(HeapTupleHeaderData)));
if (subquery_size > work_mem * 1024L)
return false;