pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: David Rowley <drowley@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Remove redundant PARTITION BY columns from WindowClauses
Date: Mon, 03 Jul 2023 00:50:04 +0000
Message-ID: <E1qG7lU-001cGs-9T@gemulon.postgresql.org> (raw)

Remove redundant PARTITION BY columns from WindowClauses

Here we adjust the query planner to have it remove items from a window
clause's PARTITION BY clause in cases where the pathkey for a column in
the PARTITION BY clause is redundant.

Doing this allows the optimization added in 9d9c02ccd to stop window
aggregation early rather than going into "pass-through" mode to find
tuples belonging to the next partition.  Also, when we manage to remove
all PARTITION BY columns, we now no longer needlessly check that the
current tuple belongs to the same partition as the last tuple in
nodeWindowAgg.c.  If the pathkey was redundant then all tuples must
contain the same value for the given redundant column, so there's no point
in checking that during execution.

Author: David Rowley
Reviewed-by: Richard Guo
Discussion: https://postgr.es/m/CAApHDvo2ji+hdxrxfXtRtsfSVw3to2o1nCO20qimw0dUGK8hcQ@mail.gmail.com

Branch
------
master

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

Modified Files
--------------
src/backend/optimizer/plan/createplan.c |  7 +----
src/backend/optimizer/plan/planner.c    | 51 +++++++++++++++++++++++++++------
src/include/nodes/parsenodes.h          |  2 ++
3 files changed, 46 insertions(+), 14 deletions(-)



Message-ID: <E1qG7lU-001cGs-9T@gemulon.postgresql.org>
Permalink:  ../E1qG7lU-001cGs-9T@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1qG7lU-001cGs-9T@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: drowley@postgresql.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Remove redundant PARTITION BY columns from WindowClauses
  In-Reply-To: <E1qG7lU-001cGs-9T@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