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

Commit5a6cc6f

Browse files
Remove hashagg_avoid_disk_plan GUC.
Note: This GUC was originally named enable_hashagg_disk when it appearedin commit1f39bce, which added disk-based hash aggregation. It wassubsequently renamed in commit92c58fd.Author: Peter GeogheganReviewed-By: Jeff Davis, Álvaro HerreraDiscussion:https://postgr.es/m/9d9d1e1252a52ea1bad84ea40dbebfd54e672a0f.camel%40j-davis.comBackpatch: 13-, where disk-based hash aggregation was introduced.
1 parent0caf1fc commit5a6cc6f

File tree

6 files changed

+56
-138
lines changed

6 files changed

+56
-138
lines changed

‎doc/src/sgml/config.sgml

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4813,23 +4813,6 @@ ANY <replaceable class="parameter">num_sync</replaceable> ( <replaceable class="
48134813
</listitem>
48144814
</varlistentry>
48154815

4816-
<varlistentry id="guc-hashagg-avoid-disk-plan" xreflabel="hashagg_avoid_disk_plan">
4817-
<term><varname>hashagg_avoid_disk_plan</varname> (<type>boolean</type>)
4818-
<indexterm>
4819-
<primary><varname>hashagg_avoid_disk_plan</varname> configuration parameter</primary>
4820-
</indexterm>
4821-
</term>
4822-
<listitem>
4823-
<para>
4824-
If set to <literal>on</literal>, causes the planner to avoid choosing
4825-
hashed aggregation plans that are expected to use the disk. If hashed
4826-
aggregation is chosen, it may still require the use of disk at
4827-
execution time, even if this parameter is enabled. The default is
4828-
<literal>off</literal>.
4829-
</para>
4830-
</listitem>
4831-
</varlistentry>
4832-
48334816
</variablelist>
48344817
</sect2>
48354818
<sect2 id="runtime-config-query-constants">

‎doc/src/sgml/release-13.sgml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -627,8 +627,7 @@ Author: Jeff Davis <jdavis@postgresql.org>
627627

628628
<para>
629629
Previously, hash aggregation was avoided if it was expected to use
630-
more than <xref linkend="guc-work-mem"/> memory. This is controlled
631-
by <xref linkend="guc-hashagg-avoid-disk-plan"/>.
630+
more than <xref linkend="guc-work-mem"/> memory.
632631
</para>
633632
</listitem>
634633

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ boolenable_tidscan = true;
130130
boolenable_sort= true;
131131
boolenable_incremental_sort= true;
132132
boolenable_hashagg= true;
133-
boolhashagg_avoid_disk_plan= true;
134133
boolenable_nestloop= true;
135134
boolenable_material= true;
136135
boolenable_mergejoin= true;

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

Lines 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 areseveral things that
4853+
* die trying. If we do have other choices, there aretwo 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
elseif (parse->hasDistinctOn|| !enable_hashagg)
48654864
allow_hash= false;/* policy-based decision not to hash */
48664865
else
4867-
{
4868-
Sizehashentrysize=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-
doublehashaggtablesize;
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-
doublehashaggtablesize;
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-
doublehashaggtablesize;
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

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,16 +1010,6 @@ static struct config_bool ConfigureNamesBool[] =
10101010
true,
10111011
NULL,NULL,NULL
10121012
},
1013-
{
1014-
{"hashagg_avoid_disk_plan",PGC_USERSET,QUERY_TUNING_METHOD,
1015-
gettext_noop("Causes the planner to avoid hashed aggregation plans that are expected to use the disk."),
1016-
NULL,
1017-
GUC_EXPLAIN
1018-
},
1019-
&hashagg_avoid_disk_plan,
1020-
false,
1021-
NULL,NULL,NULL
1022-
},
10231013
{
10241014
{"enable_material",PGC_USERSET,QUERY_TUNING_METHOD,
10251015
gettext_noop("Enables the planner's use of materialization."),

‎src/include/optimizer/cost.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ extern PGDLLIMPORT bool enable_tidscan;
5555
externPGDLLIMPORTboolenable_sort;
5656
externPGDLLIMPORTboolenable_incremental_sort;
5757
externPGDLLIMPORTboolenable_hashagg;
58-
externPGDLLIMPORTboolhashagg_avoid_disk_plan;
5958
externPGDLLIMPORTboolenable_nestloop;
6059
externPGDLLIMPORTboolenable_material;
6160
externPGDLLIMPORTboolenable_mergejoin;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp