Skip to content

Commit dd8e191

Browse files
committed
Consider disk-based hash aggregation to implement DISTINCT.
Correct oversight in 1f39bce. If enable_hashagg_disk=true, we should consider hash aggregation for DISTINCT when applicable.
1 parent 3649133 commit dd8e191

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/backend/optimizer/plan/planner.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -4868,8 +4868,8 @@ create_distinct_paths(PlannerInfo *root,
48684868
Size hashentrysize = hash_agg_entry_size(
48694869
0, cheapest_input_path->pathtarget->width, 0);
48704870

4871-
/* Allow hashing only if hashtable is predicted to fit in work_mem */
4872-
allow_hash = (hashentrysize * numDistinctRows <= work_mem * 1024L);
4871+
allow_hash = enable_hashagg_disk ||
4872+
(hashentrysize * numDistinctRows <= work_mem * 1024L);
48734873
}
48744874

48754875
if (allow_hash && grouping_is_hashable(parse->distinctClause))

0 commit comments

Comments
 (0)