pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: David G. Johnston <david.g.johnston@gmail.com>
Cc: Christopher Inokuchi <cinokuchi@gmail.com>
Cc: Greg Sabino Mullane <htamfids@gmail.com>
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: Window Functions with identical PARTITION BY and ORDER BY clauses evaluated separately
Date: Sat, 08 Mar 2025 14:50:52 -0500
Message-ID: <29119.1741463452@sss.pgh.pa.us> (raw)
In-Reply-To: <CAKFQuwZs9tZEy8TDLtqJJTAfRcLrM+i5TDEuppOXVFhhG3pg7g@mail.gmail.com>
References: <CABde6B5va2wMsnM79u_x=n9KUgfKQje_pbLROEBmA9Ru5XWidw@mail.gmail.com>
	<CAKAnmmK2EkwdfT24LUp4JBOfxdB5tT_oqdyFKC7P-_opF7js1g@mail.gmail.com>
	<CABde6B40mE4me17sKLGZ6MspZ4YiaSsK8S4FunP13c+QNT+fKA@mail.gmail.com>
	<1147307.1741392351@sss.pgh.pa.us>
	<CAKFQuwZs9tZEy8TDLtqJJTAfRcLrM+i5TDEuppOXVFhhG3pg7g@mail.gmail.com>

"David G. Johnston" <david.g.johnston@gmail.com> writes:
> On Fri, Mar 7, 2025 at 5:05 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> Perhaps the wording in section 7.2.5 could be improved; I agree
>> that "evaluated in one pass" is capable of being read in more
>> than one way, and it's not clear that it's referring to sorts.
>> Do you have any suggestions for clearer wording?

> We seem to do quite a few things that we don't tell the user about.  The
> attached patch describes those things and adds an example demonstrating
> their effects via an explain; which is the only way you can construct an
> example for this material.
> Considered a draft pending feedback to either throw it out in favor of a
> one-word/one-line fix or support for going into this amount of detail.

Meh.  This is detail that wasn't asked for and doesn't belong in this
section anyway.  (If we did want to write something like this, chapter
14 Performance Tips would be a more plausible home I think.  That'd
at least remove the problem of forward-referencing EXPLAIN output.)

For a shorter fix, maybe replace the first two sentences

    When multiple window functions are used, all the window functions
    having syntactically equivalent PARTITION BY and ORDER BY clauses
    in their window definitions are guaranteed to be evaluated in a
    single pass over the data. Therefore they will see the same sort
    ordering, even if the ORDER BY does not uniquely determine an
    ordering.

with

    When multiple window functions are used, all the window functions
    having syntactically equivalent PARTITION BY and ORDER BY clauses
    in their window definitions are guaranteed to see the same
    ordering of the input rows, even if the ORDER BY does not uniquely
    determine the ordering.

			regards, tom lane





view thread (11+ messages)  latest in thread

Message-ID: <29119.1741463452@sss.pgh.pa.us>
Permalink:  ../29119.1741463452@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/29119.1741463452@sss.pgh.pa.us

 · 

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-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, david.g.johnston@gmail.com, cinokuchi@gmail.com, htamfids@gmail.com, pgsql-bugs@lists.postgresql.org
  Subject: Re: Window Functions with identical PARTITION BY and ORDER BY clauses evaluated separately
  In-Reply-To: <29119.1741463452@sss.pgh.pa.us>

* 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