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

Commite6d3f5b

Browse files
committed
Fix hash table size estimation error in choose_hashed_distinct().
We should account for the per-group hashtable entry overhead whenconsidering whether to use a hash aggregate to implement DISTINCT. Thecomparable logic in choose_hashed_grouping() gets this right, but I thinkI omitted it here in the mistaken belief that there would be no overheadif there were no aggregate functions to be evaluated. This can result inmore than 2X underestimate of the hash table size, if the tuples beingaggregated aren't very wide. Per report from Tomas Vondra.This bug is of long standing, but per discussion we'll only back-patch into9.3. Changing the estimation behavior in stable branches seems to carry toomuch risk of destabilizing plan choices for already-tuned applications.
1 parentc9d7c19 commite6d3f5b

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2689,7 +2689,11 @@ choose_hashed_distinct(PlannerInfo *root,
26892689
* Don't do it if it doesn't look like the hashtable will fit into
26902690
* work_mem.
26912691
*/
2692+
2693+
/* Estimate per-hash-entry space at tuple width... */
26922694
hashentrysize=MAXALIGN(path_width)+MAXALIGN(sizeof(MinimalTupleData));
2695+
/* plus the per-hash-entry overhead */
2696+
hashentrysize+=hash_agg_entry_size(0);
26932697

26942698
if (hashentrysize*dNumDistinctRows>work_mem*1024L)
26952699
return false;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp