From: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Christopher Inokuchi <cinokuchi(at)gmail(dot)com>, Greg Sabino Mullane <htamfids(at)gmail(dot)com>, pgsql-bugs(at)lists(dot)postgresql(dot)org |
Subject: | Re: Window Functions with identical PARTITION BY and ORDER BY clauses evaluated separately |
Date: | 2025-03-09 01:07:26 |
Message-ID: | CAKFQuwaSSm-fe41XEGr1dNSPgnGfHZNJ0mdZmqx9tYMpFVHANg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
On Sat, Mar 8, 2025 at 12:50 PM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> "David G. Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> writes:
> > On Fri, Mar 7, 2025 at 5:05 PM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)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.)
>
Thank you for the input. I figured that would be the response and am fine
with it. I took a look at Chapter 14 and agree it could fit there but that
just brought up more thoughts. I'll start a separate thread for all that.
> For a shorter fix
>
> 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.
>
WFM, the key point is removing the problematic wording and I do find this
reads better in the end.
However, I'm having trouble understanding the purpose of the word
"syntactically" here. Or even using the "clauses" at all. Why not:
"When multiple window functions are used, all the window functions having
the same partitioning and ordering expressions in their window definitions
are guaranteed to see the same ordering of the input rows, even if
the ordering is not deterministic."
David J.
From | Date | Subject | |
---|---|---|---|
Next Message | David Rowley | 2025-03-09 07:22:30 | Re: Error from array_agg when table has many rows |
Previous Message | Tom Lane | 2025-03-08 19:50:52 | Re: Window Functions with identical PARTITION BY and ORDER BY clauses evaluated separately |