pgsql: Add an enable_groupagg GUC parameter

Поиск
Список
Период
Сортировка
Искать

pgsql: Add an enable_groupagg GUC parameter

От:
Richard Guo <rguo@postgresql.org>
Дата:
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 
Co-authored-by: Richard Guo 
Reviewed-by: Ashutosh Bapat 
Reviewed-by: David Rowley 
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(-)

FAQ