Re: Multiple Aggregations Order

From: João Haas <joao(dot)ca(dot)haas(at)gmail(dot)com>
To: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Multiple Aggregations Order
Date: 2020-01-14 21:17:22
Message-ID: CAEi5ktJe0W1fTX2Xo97+xCAhU8=TBqDQx4VwM0vqvH8CNLOURg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(dot)g(dot)johnston(at)gmail(dot)com> wrote:

> On Tuesday, January 14, 2020, João Haas <joao(dot)ca(dot)haas(at)gmail(dot)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.
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Thomas Kellerer 2020-01-14 21:48:00 Re: Multiple Aggregations Order
Previous Message João Haas 2020-01-14 21:03:29 Re: Multiple Aggregations Order