Re: Document aggregate functions better w.r.t. ORDER BY - Mailing list pgsql-hackers

From David G. Johnston
Subject Re: Document aggregate functions better w.r.t. ORDER BY
Date
Msg-id CAKFQuwZx6_PTtVzWuUoaYRKu2NQvs+2pWc1nU7MWaikinD9Bqw@mail.gmail.com
Whole thread Raw
In response to Re: Document aggregate functions better w.r.t. ORDER BY  (Bruce Momjian <bruce@momjian.us>)
Responses Re: Document aggregate functions better w.r.t. ORDER BY
List pgsql-hackers
On Wed, Oct 25, 2023 at 8:36 AM Bruce Momjian <bruce@momjian.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.

pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: Container Types
Next
From: Bruce Momjian
Date:
Subject: Re: Document aggregate functions better w.r.t. ORDER BY