pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alexander Korotkov <akorotkov@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Restore preprocess_groupclause()
Date: Thu, 06 Jun 2024 10:45:49 +0000
Message-ID: <E1sFAcu-000Fmy-M0@gemulon.postgresql.org> (raw)

Restore preprocess_groupclause()

0452b461bc made optimizer explore alternative orderings of group-by pathkeys.
It eliminated preprocess_groupclause(), which was intended to match items
between GROUP BY and ORDER BY.  Instead, get_useful_group_keys_orderings()
function generates orderings of GROUP BY elements at the time of grouping
paths generation.  The get_useful_group_keys_orderings() function takes into
account 3 orderings of GROUP BY pathkeys and clauses: original order as written
in GROUP BY, matching ORDER BY clauses as much as possible, and matching the
input path as much as possible.  Given that even before 0452b461b,
preprocess_groupclause() could change the original order of GROUP BY clauses
we don't need to consider it apart from ordering matching ORDER BY clauses.

This commit restores preprocess_groupclause() to provide an ordering of
GROUP BY elements matching ORDER BY before generation of paths.  The new
version of preprocess_groupclause() takes into account an incremental sort.
The get_useful_group_keys_orderings() function now takes into 2 orderings of
GROUP BY elements: the order generated preprocess_groupclause() and the order
matching the input path as much as possible.

Discussion: https://postgr.es/m/CAPpHfdvyWLMGwvxaf%3D7KAp-z-4mxbSH8ti2f6mNOQv5metZFzg%40mail.gmail.com
Author: Alexander Korotkov
Reviewed-by: Andrei Lepikhov, Pavel Borisov

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/505c008ca37c4f6f2fffcde370b5d8354c4d4dc3

Modified Files
--------------
src/backend/optimizer/path/pathkeys.c             |  55 +----------
src/backend/optimizer/plan/planner.c              | 108 +++++++++++++++++++---
src/include/nodes/pathnodes.h                     |   6 +-
src/test/regress/expected/partition_aggregate.out |   6 +-
4 files changed, 108 insertions(+), 67 deletions(-)



Message-ID: <E1sFAcu-000Fmy-M0@gemulon.postgresql.org>
Permalink:  ../E1sFAcu-000Fmy-M0@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1sFAcu-000Fmy-M0@gemulon.postgresql.org

 · 

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: pgsql-committers@postgresql.org
  Cc: akorotkov@postgresql.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Restore preprocess_groupclause()
  In-Reply-To: <E1sFAcu-000Fmy-M0@gemulon.postgresql.org>

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

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