From: | Dimitrios Apostolou <jimis(at)gmx(dot)net> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | pgsql-general(at)lists(dot)postgresql(dot)org |
Subject: | Re: array_agg() does not stop aggregating according to HAVING clause |
Date: | 2024-08-17 15:35:39 |
Message-ID: | 3f255b39-e0a7-e04e-0747-c98b13a4e0f6@gmx.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
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
From | Date | Subject | |
---|---|---|---|
Next Message | Greg Sabino Mullane | 2024-08-17 15:55:56 | Re: Column type modification in big tables |
Previous Message | Tom Lane | 2024-08-17 15:15:11 | Re: array_agg() does not stop aggregating according to HAVING clause |