Re: Document aggregate functions better w.r.t. ORDER BY

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Document aggregate functions better w.r.t. ORDER BY
Date: 2023-10-25 23:14:11
Message-ID: CAKFQuwZx6_PTtVzWuUoaYRKu2NQvs+2pWc1nU7MWaikinD9Bqw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Oct 25, 2023 at 8:36 AM Bruce Momjian <bruce(at)momjian(dot)us> wrote:

> On Tue, Oct 24, 2023 at 06:45:48PM -0700, David G. Johnston wrote:
> > I'd prefer to keep pointing out that the ones documented are those whose
> > outputs will vary due to ordering.
>
> Okay, I re-added it in the attached patch, and tightened up the text.
>

Thanks

> I think you are right that it belongs in the syntax section; we cover
> ordering extensively there. We already have queries there, but not
> output, so I moved the relevant examples to there and replaced the
> example that had no output.
>

Thanks

> > The same goes for the special knowledge of floating point behavior for
> why
> > we've chosen to document avg/sum, something that typically doesn't care
> about
> > order, as having an optional order by.
>
> The floating example seems too obscure to mention in our function docs.
> I can put a sentence in the syntax docs, but is there value in
> explaining that to users? How it that helpful? Example?
>
>
Yeah, we punt on the entire concept in the data type section:

"Managing these errors and how they propagate through calculations is the
subject of an entire branch of mathematics and computer science and will
not be discussed here," ...

Also, I'm now led to believe that the relevant IEEE 754 floating point
addition is indeed commutative. Given that, I am inclined to simply not
add the order by clause at all to those four functions. (actually, you
already got rid of the avg()s but the sum()s are still present, so just
those two).

David J.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2023-10-25 23:22:29 Re: Document aggregate functions better w.r.t. ORDER BY
Previous Message Andres Freund 2023-10-25 23:01:51 Re: Container Types