Re: Multiple Aggregations Order - Mailing list pgsql-general

From João Haas
Subject Re: Multiple Aggregations Order
Date
Msg-id CAEi5ktJe0W1fTX2Xo97+xCAhU8=TBqDQx4VwM0vqvH8CNLOURg@mail.gmail.com
Whole thread Raw
In response to Re: Multiple Aggregations Order  ("David G. Johnston" <david.g.johnston@gmail.com>)
List pgsql-general
I also thought about that. The 'issue', is that when you call array_agg in a row/type, it casts the entire thing in a string. But some of the aggregation fields are jsonb fields, which are also casted to strings, with extra escapes. Then, I'm also using Django, which seems to mess the string even more. I could try to denormalize this whole mess, but I don't think the overhead of sorting each agg is enough for this. Also, Django handles these extra fields really well on raw queries, so it's not an issue having a lot of fields.

On Tue, Jan 14, 2020 at 5:43 PM David G. Johnston <david.g.johnston@gmail.com> wrote:
On Tuesday, January 14, 2020, João Haas <joao.ca.haas@gmail.com> wrote:
SELECT tb.*, array_agg(conn.child_id), array_agg(conn.kind)


Create a custom type (using row(...) might work...?) with the relevant fields and “...array_agg((child_id, kind)::custom_type order by ...”?

David J.

pgsql-general by date:

Previous
From: João Haas
Date:
Subject: Re: Multiple Aggregations Order
Next
From: Thomas Kellerer
Date:
Subject: Re: Multiple Aggregations Order