Paul Jungwirth <pj@xxxxxxxxxxxxxxxxxxxxxxxx> writes: > On 04/10/2017 11:35 AM, Tom Lane wrote: >> I'm not very keen on recommending that the OP insert an ORDER BY into >> each aggregate call, because that would cause a separate sort for each >> aggregate (unless someone's improved that recently while I wasn't >> looking). > I mentioned this in my other email, upon a second look I was misreading > the EXPLAIN output. (The sort was for the GROUP BY, not the individual > ORDER BYs.) Do aggregate function sorts even show up in EXPLAIN? They don't. It's not a plannable behavior, just something that's hard-wired into nodeAgg.c. I'd like to see that improved someday, but I don't think it's really high on anyone's priority list. regards, tom lane -- Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general