]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Add an enable_groupagg GUC parameter
authorRichard Guo <rguo@postgresql.org>
Thu, 9 Jul 2026 00:44:56 +0000 (09:44 +0900)
committerRichard Guo <rguo@postgresql.org>
Thu, 9 Jul 2026 00:44:56 +0000 (09:44 +0900)
commite01b23b84e4346c1941e2aad78e3d80a5498038d
treedbf5b3f514810574f1aba9454b3cbc685eb2ba19
parentff076c042a7467c2870d6dac4eba48651498d57b
Add an enable_groupagg GUC parameter

We've long had enable_hashagg to discourage hashed aggregation, but
there was no equivalent for grouping that works by reading presorted
input.  That's handy when investigating planner cost misestimates, and
as an escape hatch when a sorted grouping plan is chosen over a much
cheaper hashed one.

enable_groupagg (on by default) covers the GroupAggregate and Group
nodes, the sort-based Unique step used for DISTINCT and semijoin
unique-ification, and the sorted mode of SetOp.  It isn't a hard
switch; it only bumps disabled_nodes, so plans with no other choice
are still produced.

Several regression and module tests had been setting enable_sort off,
and one enable_indexscan off, only to force a hashed plan.  Use
enable_groupagg there instead, where that was the real intent.  In
union.sql this also lets us test the hashed UNION path, which we had
no way to reach before.

Author: Tatsuro Yamada <yamatattsu@gmail.com>
Co-authored-by: Richard Guo <guofenglinux@gmail.com>
Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Reviewed-by: David Rowley <dgrowleyml@gmail.com>
Discussion: https://postgr.es/m/CAOKkKFvYHSEsFazkrf9bRH14p-H27XMaqbZfRYjS6EHBruvZMQ@mail.gmail.com
29 files changed:
contrib/hstore/expected/hstore.out
contrib/hstore/sql/hstore.sql
contrib/ltree/expected/ltree.out
contrib/ltree/sql/ltree.sql
doc/src/sgml/config.sgml
src/backend/optimizer/path/costsize.c
src/backend/optimizer/util/pathnode.c
src/backend/utils/misc/guc_parameters.dat
src/backend/utils/misc/postgresql.conf.sample
src/include/optimizer/cost.h
src/test/modules/injection_points/expected/hashagg.out
src/test/modules/injection_points/sql/hashagg.sql
src/test/regress/expected/aggregates.out
src/test/regress/expected/groupingsets.out
src/test/regress/expected/jsonb.out
src/test/regress/expected/multirangetypes.out
src/test/regress/expected/rangetypes.out
src/test/regress/expected/select_distinct.out
src/test/regress/expected/subselect.out
src/test/regress/expected/sysviews.out
src/test/regress/expected/union.out
src/test/regress/sql/aggregates.sql
src/test/regress/sql/groupingsets.sql
src/test/regress/sql/jsonb.sql
src/test/regress/sql/multirangetypes.sql
src/test/regress/sql/rangetypes.sql
src/test/regress/sql/select_distinct.sql
src/test/regress/sql/subselect.sql
src/test/regress/sql/union.sql