pgsql: Improve EXPLAIN's display of window functions.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Improve EXPLAIN's display of window functions.
Date: 2025-03-11 15:20:01
Message-ID: E1ts1Oj-001wle-2J@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Improve EXPLAIN's display of window functions.

Up to now we just punted on showing the window definitions used
in a plan, with window function calls represented as "OVER (?)".
To improve that, show the window definition implemented by each
WindowAgg plan node, and reference their window names in OVER.
For nameless window clauses generated by "OVER (...)", assign
unique names w1, w2, etc.

In passing, re-order the properties shown for a WindowAgg node
so that the Run Condition (if any) appears after the Window
property and before the Filter (if any). This seems more
sensible since the Run Condition is associated with the Window
and acts before the Filter.

Thanks to David G. Johnston and Álvaro Herrera for design
suggestions.

Author: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Reviewed-by: David Rowley <dgrowleyml(at)gmail(dot)com>
Discussion: https://postgr.es/m/144530.1741469955@sss.pgh.pa.us

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/8b1b342544b69b281ffd3aafe594aec629ec4d3c

Modified Files
--------------
contrib/postgres_fdw/expected/postgres_fdw.out | 25 +-
src/backend/commands/explain.c | 117 +++++++-
src/backend/optimizer/plan/createplan.c | 39 +--
src/backend/optimizer/plan/planner.c | 51 ++++
src/backend/utils/adt/ruleutils.c | 150 ++++++++---
src/include/nodes/plannodes.h | 3 +
src/include/utils/ruleutils.h | 5 +
src/test/regress/expected/box.out | 14 +-
src/test/regress/expected/create_index_spgist.out | 42 +--
src/test/regress/expected/explain.out | 45 +++-
src/test/regress/expected/generated_virtual.out | 3 +-
src/test/regress/expected/groupingsets.out | 12 +-
src/test/regress/expected/partition_prune.out | 4 +-
src/test/regress/expected/polygon.out | 3 +-
src/test/regress/expected/select_parallel.out | 7 +-
src/test/regress/expected/sqljson.out | 18 +-
src/test/regress/expected/window.out | 308 +++++++++++++---------
src/test/regress/sql/explain.sql | 5 +
18 files changed, 598 insertions(+), 253 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Masahiko Sawada 2025-03-11 16:30:14 pgsql: pg_logicalinspect: Stabilize isolation tests.
Previous Message Peter Geoghegan 2025-03-11 14:36:34 pgsql: nbtree: Make BTMaxItemSize into object-like macro.