public inbox for [email protected]  
help / color / mirror / Atom feed
From: Richard Guo <[email protected]>
To: [email protected]
Subject: pgsql: Add an enable_groupagg GUC parameter
Date: Thu, 09 Jul 2026 00:45:23 +0000
Message-ID: <[email protected]> (raw)

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 <[email protected]>
Co-authored-by: Richard Guo <[email protected]>
Reviewed-by: Ashutosh Bapat <[email protected]>
Reviewed-by: David Rowley <[email protected]>
Discussion: https://postgr.es/m/CAOKkKFvYHSEsFazkrf9bRH14p-H27XMaqbZfRYjS6EHBruvZMQ@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/e01b23b84e4346c1941e2aad78e3d80a5498038d

Modified Files
--------------
contrib/hstore/expected/hstore.out                 |  4 +--
contrib/hstore/sql/hstore.sql                      |  4 +--
contrib/ltree/expected/ltree.out                   |  4 +--
contrib/ltree/sql/ltree.sql                        |  4 +--
doc/src/sgml/config.sgml                           | 14 ++++++++
src/backend/optimizer/path/costsize.c              | 33 ++++++++++++++++---
src/backend/optimizer/util/pathnode.c              | 20 ++++++++++++
src/backend/utils/misc/guc_parameters.dat          |  7 ++++
src/backend/utils/misc/postgresql.conf.sample      |  1 +
src/include/optimizer/cost.h                       |  1 +
.../modules/injection_points/expected/hashagg.out  |  2 +-
src/test/modules/injection_points/sql/hashagg.sql  |  2 +-
src/test/regress/expected/aggregates.out           | 10 +++---
src/test/regress/expected/groupingsets.out         |  8 ++---
src/test/regress/expected/jsonb.out                |  6 ++--
src/test/regress/expected/multirangetypes.out      |  4 +--
src/test/regress/expected/rangetypes.out           |  4 +--
src/test/regress/expected/select_distinct.out      |  4 +--
src/test/regress/expected/subselect.out            |  2 +-
src/test/regress/expected/sysviews.out             |  3 +-
src/test/regress/expected/union.out                | 37 ++++++++++++++--------
src/test/regress/sql/aggregates.sql                | 10 +++---
src/test/regress/sql/groupingsets.sql              |  8 ++---
src/test/regress/sql/jsonb.sql                     |  6 ++--
src/test/regress/sql/multirangetypes.sql           |  4 +--
src/test/regress/sql/rangetypes.sql                |  4 +--
src/test/regress/sql/select_distinct.sql           |  4 +--
src/test/regress/sql/subselect.sql                 |  2 +-
src/test/regress/sql/union.sql                     | 16 +++++-----
29 files changed, 153 insertions(+), 75 deletions(-)



reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: pgsql: Add an enable_groupagg GUC parameter
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox