Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1c1ecd5

Browse files
committed
Improve planner estimates for size of tuple hash tables.
1 parent485375a commit1c1ecd5

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

‎src/backend/optimizer/plan/planner.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/optimizer/plan/planner.c,v 1.199 2006/03/05 15:58:29 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/optimizer/plan/planner.c,v 1.200 2006/06/28 20:04:38 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -1298,7 +1298,7 @@ choose_hashed_grouping(PlannerInfo *root, double tuple_fraction,
12981298
}
12991299

13001300
/* Estimate per-hash-entry space at tuple width... */
1301-
hashentrysize=cheapest_path_width;
1301+
hashentrysize=MAXALIGN(cheapest_path_width)+MAXALIGN(sizeof(MinimalTupleData));
13021302
/* plus space for pass-by-ref transition values... */
13031303
hashentrysize+=agg_counts->transitionSpace;
13041304
/* plus the per-hash-entry overhead */

‎src/backend/optimizer/plan/subselect.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
99
* IDENTIFICATION
10-
* $PostgreSQL: pgsql/src/backend/optimizer/plan/subselect.c,v 1.107 2006/05/03 00:24:56 tgl Exp $
10+
* $PostgreSQL: pgsql/src/backend/optimizer/plan/subselect.c,v 1.108 2006/06/28 20:04:38 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -585,11 +585,13 @@ subplan_is_hashable(SubLink *slink, SubPlan *node)
585585
return false;
586586

587587
/*
588-
* The estimated size of the subquery result must fit in work_mem. (XXX
589-
* what about hashtable overhead?)
588+
* The estimated size of the subquery result must fit in work_mem.
589+
* (Note: we use sizeof(HeapTupleHeaderData) here even though the tuples
590+
* will actually be stored as MinimalTuples; this provides some fudge
591+
* factor for hashtable overhead.)
590592
*/
591593
subquery_size=node->plan->plan_rows*
592-
(MAXALIGN(node->plan->plan_width)+MAXALIGN(sizeof(HeapTupleData)));
594+
(MAXALIGN(node->plan->plan_width)+MAXALIGN(sizeof(HeapTupleHeaderData)));
593595
if (subquery_size>work_mem*1024L)
594596
return false;
595597

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp