aboutsummaryrefslogtreecommitdiff
path: root/src/backend/optimizer/plan/planner.c
diff options
context:
space:
mode:
authorJeff Davis <jdavis@postgresql.org>2020-02-06 11:49:56 -0800
committerJeff Davis <jdavis@postgresql.org>2020-02-06 11:49:56 -0800
commit7d4395d0a11589aa450a073d658c49b420f4493f (patch)
treeb9be6165922e73d2351d8565f9051184ae56f036 /src/backend/optimizer/plan/planner.c
parentc02fdc9223015c5c386abfa00c47fc7f4c845161 (diff)
downloadpostgresql-7d4395d0a11589aa450a073d658c49b420f4493f.tar.gz
postgresql-7d4395d0a11589aa450a073d658c49b420f4493f.zip
Refactor hash_agg_entry_size().
Consolidate the calculations for hash table size estimation. This will help with upcoming Hash Aggregation work that will add additional call sites.
Diffstat (limited to 'src/backend/optimizer/plan/planner.c')
-rw-r--r--src/backend/optimizer/plan/planner.c9
1 files changed, 2 insertions, 7 deletions
diff --git a/src/backend/optimizer/plan/planner.c b/src/backend/optimizer/plan/planner.c
index d6f21535937..b44efd6314c 100644
--- a/src/backend/optimizer/plan/planner.c
+++ b/src/backend/optimizer/plan/planner.c
@@ -4867,13 +4867,8 @@ create_distinct_paths(PlannerInfo *root,
allow_hash = false; /* policy-based decision not to hash */
else
{
- Size hashentrysize;
-
- /* Estimate per-hash-entry space at tuple width... */
- hashentrysize = MAXALIGN(cheapest_input_path->pathtarget->width) +
- MAXALIGN(SizeofMinimalTupleHeader);
- /* plus the per-hash-entry overhead */
- hashentrysize += hash_agg_entry_size(0);
+ Size hashentrysize = hash_agg_entry_size(
+ 0, cheapest_input_path->pathtarget->width, 0);
/* Allow hashing only if hashtable is predicted to fit in work_mem */
allow_hash = (hashentrysize * numDistinctRows <= work_mem * 1024L);