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

Appearance settings

Commit bcbf944

Browse filesBrowse files
Remove hashagg_avoid_disk_plan GUC.
Note: This GUC was originally named enable_hashagg_disk when it appeared in commit 1f39bce, which added disk-based hash aggregation. It was subsequently renamed in commit 92c58fd. Author: Peter Geoghegan Reviewed-By: Jeff Davis, Álvaro Herrera Discussion: https://postgr.es/m/9d9d1e1252a52ea1bad84ea40dbebfd54e672a0f.camel%40j-davis.com Backpatch: 13-, where disk-based hash aggregation was introduced.
1 parent a3ab7a7 commit bcbf944
Copy full SHA for bcbf944

File tree

Expand file treeCollapse file tree

5 files changed

+55
-136
lines changed
Filter options
Expand file treeCollapse file tree

5 files changed

+55
-136
lines changed

‎doc/src/sgml/config.sgml

Copy file name to clipboardExpand all lines: doc/src/sgml/config.sgml
-17Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4840,23 +4840,6 @@ ANY <replaceable class="parameter">num_sync</replaceable> ( <replaceable class="
48404840
</listitem>
48414841
</varlistentry>
48424842

4843-
<varlistentry id="guc-hashagg-avoid-disk-plan" xreflabel="hashagg_avoid_disk_plan">
4844-
<term><varname>hashagg_avoid_disk_plan</varname> (<type>boolean</type>)
4845-
<indexterm>
4846-
<primary><varname>hashagg_avoid_disk_plan</varname> configuration parameter</primary>
4847-
</indexterm>
4848-
</term>
4849-
<listitem>
4850-
<para>
4851-
If set to <literal>on</literal>, causes the planner to avoid choosing
4852-
hashed aggregation plans that are expected to use the disk. If hashed
4853-
aggregation is chosen, it may still require the use of disk at
4854-
execution time, even if this parameter is enabled. The default is
4855-
<literal>off</literal>.
4856-
</para>
4857-
</listitem>
4858-
</varlistentry>
4859-
48604843
</variablelist>
48614844
</sect2>
48624845
<sect2 id="runtime-config-query-constants">

‎src/backend/optimizer/path/costsize.c

Copy file name to clipboardExpand all lines: src/backend/optimizer/path/costsize.c
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ bool enable_tidscan = true;
130130
bool enable_sort = true;
131131
bool enable_incremental_sort = true;
132132
bool enable_hashagg = true;
133-
bool hashagg_avoid_disk_plan = true;
134133
bool enable_nestloop = true;
135134
bool enable_material = true;
136135
bool enable_mergejoin = true;

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

Copy file name to clipboardExpand all lines: src/backend/optimizer/plan/planner.c
+55-107Lines changed: 55 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -4850,11 +4850,10 @@ create_distinct_paths(PlannerInfo *root,
48504850
* Consider hash-based implementations of DISTINCT, if possible.
48514851
*
48524852
* If we were not able to make any other types of path, we *must* hash or
4853-
* die trying. If we do have other choices, there are several things that
4853+
* die trying. If we do have other choices, there are two things that
48544854
* should prevent selection of hashing: if the query uses DISTINCT ON
48554855
* (because it won't really have the expected behavior if we hash), or if
4856-
* enable_hashagg is off, or if it looks like the hashtable will exceed
4857-
* work_mem.
4856+
* enable_hashagg is off.
48584857
*
48594858
* Note: grouping_is_hashable() is much more expensive to check than the
48604859
* other gating conditions, so we want to do it last.
@@ -4864,12 +4863,7 @@ create_distinct_paths(PlannerInfo *root,
48644863
else if (parse->hasDistinctOn || !enable_hashagg)
48654864
allow_hash = false; /* policy-based decision not to hash */
48664865
else
4867-
{
4868-
Size hashentrysize = hash_agg_entry_size(0, cheapest_input_path->pathtarget->width, 0);
4869-
4870-
allow_hash = !hashagg_avoid_disk_plan ||
4871-
(hashentrysize * numDistinctRows <= work_mem * 1024L);
4872-
}
4866+
allow_hash = true; /* default */
48734867

48744868
if (allow_hash && grouping_is_hashable(parse->distinctClause))
48754869
{
@@ -6749,8 +6743,6 @@ add_paths_to_grouping_rel(PlannerInfo *root, RelOptInfo *input_rel,
67496743

67506744
if (can_hash)
67516745
{
6752-
double hashaggtablesize;
6753-
67546746
if (parse->groupingSets)
67556747
{
67566748
/*
@@ -6762,63 +6754,41 @@ add_paths_to_grouping_rel(PlannerInfo *root, RelOptInfo *input_rel,
67626754
}
67636755
else
67646756
{
6765-
hashaggtablesize = estimate_hashagg_tablesize(cheapest_path,
6766-
agg_costs,
6767-
dNumGroups);
6768-
67696757
/*
6770-
* Provided that the estimated size of the hashtable does not
6771-
* exceed work_mem, we'll generate a HashAgg Path, although if we
6772-
* were unable to sort above, then we'd better generate a Path, so
6773-
* that we at least have one.
6758+
* Generate a HashAgg Path. We just need an Agg over the
6759+
* cheapest-total input path, since input order won't matter.
67746760
*/
6775-
if (!hashagg_avoid_disk_plan ||
6776-
hashaggtablesize < work_mem * 1024L ||
6777-
grouped_rel->pathlist == NIL)
6778-
{
6779-
/*
6780-
* We just need an Agg over the cheapest-total input path,
6781-
* since input order won't matter.
6782-
*/
6783-
add_path(grouped_rel, (Path *)
6784-
create_agg_path(root, grouped_rel,
6785-
cheapest_path,
6786-
grouped_rel->reltarget,
6787-
AGG_HASHED,
6788-
AGGSPLIT_SIMPLE,
6789-
parse->groupClause,
6790-
havingQual,
6791-
agg_costs,
6792-
dNumGroups));
6793-
}
6761+
add_path(grouped_rel, (Path *)
6762+
create_agg_path(root, grouped_rel,
6763+
cheapest_path,
6764+
grouped_rel->reltarget,
6765+
AGG_HASHED,
6766+
AGGSPLIT_SIMPLE,
6767+
parse->groupClause,
6768+
havingQual,
6769+
agg_costs,
6770+
dNumGroups));
67946771
}
67956772

67966773
/*
67976774
* Generate a Finalize HashAgg Path atop of the cheapest partially
6798-
* grouped path, assuming there is one. Once again, we'll only do this
6799-
* if it looks as though the hash table won't exceed work_mem.
6775+
* grouped path, assuming there is one
68006776
*/
68016777
if (partially_grouped_rel && partially_grouped_rel->pathlist)
68026778
{
68036779
Path *path = partially_grouped_rel->cheapest_total_path;
68046780

6805-
hashaggtablesize = estimate_hashagg_tablesize(path,
6806-
agg_final_costs,
6807-
dNumGroups);
6808-
6809-
if (!hashagg_avoid_disk_plan ||
6810-
hashaggtablesize < work_mem * 1024L)
6811-
add_path(grouped_rel, (Path *)
6812-
create_agg_path(root,
6813-
grouped_rel,
6814-
path,
6815-
grouped_rel->reltarget,
6816-
AGG_HASHED,
6817-
AGGSPLIT_FINAL_DESERIAL,
6818-
parse->groupClause,
6819-
havingQual,
6820-
agg_final_costs,
6821-
dNumGroups));
6781+
add_path(grouped_rel, (Path *)
6782+
create_agg_path(root,
6783+
grouped_rel,
6784+
path,
6785+
grouped_rel->reltarget,
6786+
AGG_HASHED,
6787+
AGGSPLIT_FINAL_DESERIAL,
6788+
parse->groupClause,
6789+
havingQual,
6790+
agg_final_costs,
6791+
dNumGroups));
68226792
}
68236793
}
68246794

@@ -7171,65 +7141,43 @@ create_partial_grouping_paths(PlannerInfo *root,
71717141
}
71727142
}
71737143

7144+
/*
7145+
* Add a partially-grouped HashAgg Path where possible
7146+
*/
71747147
if (can_hash && cheapest_total_path != NULL)
71757148
{
7176-
double hashaggtablesize;
7177-
71787149
/* Checked above */
71797150
Assert(parse->hasAggs || parse->groupClause);
71807151

7181-
hashaggtablesize =
7182-
estimate_hashagg_tablesize(cheapest_total_path,
7183-
agg_partial_costs,
7184-
dNumPartialGroups);
7185-
7186-
/*
7187-
* Tentatively produce a partial HashAgg Path, depending on if it
7188-
* looks as if the hash table will fit in work_mem.
7189-
*/
7190-
if ((!hashagg_avoid_disk_plan || hashaggtablesize < work_mem * 1024L) &&
7191-
cheapest_total_path != NULL)
7192-
{
7193-
add_path(partially_grouped_rel, (Path *)
7194-
create_agg_path(root,
7195-
partially_grouped_rel,
7196-
cheapest_total_path,
7197-
partially_grouped_rel->reltarget,
7198-
AGG_HASHED,
7199-
AGGSPLIT_INITIAL_SERIAL,
7200-
parse->groupClause,
7201-
NIL,
7202-
agg_partial_costs,
7203-
dNumPartialGroups));
7204-
}
7152+
add_path(partially_grouped_rel, (Path *)
7153+
create_agg_path(root,
7154+
partially_grouped_rel,
7155+
cheapest_total_path,
7156+
partially_grouped_rel->reltarget,
7157+
AGG_HASHED,
7158+
AGGSPLIT_INITIAL_SERIAL,
7159+
parse->groupClause,
7160+
NIL,
7161+
agg_partial_costs,
7162+
dNumPartialGroups));
72057163
}
72067164

7165+
/*
7166+
* Now add a partially-grouped HashAgg partial Path where possible
7167+
*/
72077168
if (can_hash && cheapest_partial_path != NULL)
72087169
{
7209-
double hashaggtablesize;
7210-
7211-
hashaggtablesize =
7212-
estimate_hashagg_tablesize(cheapest_partial_path,
7213-
agg_partial_costs,
7214-
dNumPartialPartialGroups);
7215-
7216-
/* Do the same for partial paths. */
7217-
if ((!hashagg_avoid_disk_plan ||
7218-
hashaggtablesize < work_mem * 1024L) &&
7219-
cheapest_partial_path != NULL)
7220-
{
7221-
add_partial_path(partially_grouped_rel, (Path *)
7222-
create_agg_path(root,
7223-
partially_grouped_rel,
7224-
cheapest_partial_path,
7225-
partially_grouped_rel->reltarget,
7226-
AGG_HASHED,
7227-
AGGSPLIT_INITIAL_SERIAL,
7228-
parse->groupClause,
7229-
NIL,
7230-
agg_partial_costs,
7231-
dNumPartialPartialGroups));
7232-
}
7170+
add_partial_path(partially_grouped_rel, (Path *)
7171+
create_agg_path(root,
7172+
partially_grouped_rel,
7173+
cheapest_partial_path,
7174+
partially_grouped_rel->reltarget,
7175+
AGG_HASHED,
7176+
AGGSPLIT_INITIAL_SERIAL,
7177+
parse->groupClause,
7178+
NIL,
7179+
agg_partial_costs,
7180+
dNumPartialPartialGroups));
72337181
}
72347182

72357183
/*

‎src/backend/utils/misc/guc.c

Copy file name to clipboardExpand all lines: src/backend/utils/misc/guc.c
-10Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,16 +1006,6 @@ static struct config_bool ConfigureNamesBool[] =
10061006
true,
10071007
NULL, NULL, NULL
10081008
},
1009-
{
1010-
{"hashagg_avoid_disk_plan", PGC_USERSET, QUERY_TUNING_METHOD,
1011-
gettext_noop("Causes the planner to avoid hashed aggregation plans that are expected to use the disk."),
1012-
NULL,
1013-
GUC_EXPLAIN
1014-
},
1015-
&hashagg_avoid_disk_plan,
1016-
false,
1017-
NULL, NULL, NULL
1018-
},
10191009
{
10201010
{"enable_material", PGC_USERSET, QUERY_TUNING_METHOD,
10211011
gettext_noop("Enables the planner's use of materialization."),

‎src/include/optimizer/cost.h

Copy file name to clipboardExpand all lines: src/include/optimizer/cost.h
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ extern PGDLLIMPORT bool enable_tidscan;
5555
extern PGDLLIMPORT bool enable_sort;
5656
extern PGDLLIMPORT bool enable_incremental_sort;
5757
extern PGDLLIMPORT bool enable_hashagg;
58-
extern PGDLLIMPORT bool hashagg_avoid_disk_plan;
5958
extern PGDLLIMPORT bool enable_nestloop;
6059
extern PGDLLIMPORT bool enable_material;
6160
extern PGDLLIMPORT bool enable_mergejoin;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.