On Sat, 3 Dec 2022 at 20:36, Ankit Kumar Pandey <itsanki...@gmail.com> wrote: > Shouldn't this be an acceptable tradeoff if someone wants to perform > extra operation in plain old aggregates? Although I am not sure how much > this extra memory and compute usage is considered as acceptable.
We do our best to ensure that a given executor node never uses more than work_mem. Certainly, we still do have nodes that can exceed this by a long way. It would be unlikely that we'd accept anything new that could do this. Since nodeWindowAgg.c already can use up to work_mem for the tuplestore, it does not seem unreasonable that if there is a DISTINCT aggregate that you could use 50% of work_mem for each, that is, providing you can code it in such a way that you only allocate one of these at once, i.e not allocate one per DISTINCT aggregate all at once. David