public inbox for [email protected]
help / color / mirror / Atom feedFrom: Dimitrios Apostolou <[email protected]>
To: Tom Lane <[email protected]>
Cc: [email protected]
Subject: Re: array_agg() does not stop aggregating according to HAVING clause
Date: Sat, 17 Aug 2024 17:35:39 +0200 (CEST)
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
<[email protected]>
On Sat, 17 Aug 2024, Tom Lane wrote:
> Well, yes: the two aggregates (array_agg and count) are computed
> concurrently in a single Aggregate plan node scanning the output
> of the JOIN. There's no way to apply the HAVING filter until
> after the aggregation is finished.
>
> I think this approach is basically forced by the SQL standard's
> semantics for grouping/aggregation.
FWIW I also tried:
HAVING array_length(array_agg(run_n), 1) < 10;
but I saw the same amount of temp files, at least in the short duration of
my test run.
Thank you, I will split this into two passes like you suggested. It's just
that I'm doing another 3 passes over this table for different things I
calculate (different GROUP BY, different WHERE clauses) and I was hoping
to minimize the time spent. But avoiding the array_agg() over everything
is my top priority ATM so I'll definitely try.
Regards,
Dimitris
view thread (3+ messages)
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected]
Subject: Re: array_agg() does not stop aggregating according to HAVING clause
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox