Partial Mode in Aggregate Functions

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Marcos Pegoraro <marcos(at)f10(dot)com(dot)br>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Partial Mode in Aggregate Functions
Date: 2026-02-21 15:01:08
Message-ID: CAKFQuwZh3613aBp93tZcq3vniB3TXfFkyua_QUFgGo=BvoRegw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Saturday, February 21, 2026, Marcos Pegoraro <marcos(at)f10(dot)com(dot)br> wrote:
>
> Is it related only to parallel or any other optimization ?
>
>
Yes, see create aggregate for what is required when setting partial
aggregation to true. The explanation on [0] (aggregate function reference
page) regarding why json creation functions show false is also informative.

>
> And all aggregate functions can have FILTER ?
>

Yes, the executor handles filter and simply omits invoking the aggregate if
the row does not pass the filter. The aggregates have no awareness they
have been filtered. Yes, one must reason their way to this, it isn’t
spelled out anywhere that I recall.

> I'm not exactly sure how to explain this case better, but I think it needs
> better wording.
>

I would agree. Or a cross-reference at least. It’s also another instance
of weasel-wording that seems to just invite doubt/questions. But it does
say optimizations which means it does not affect the rows returned, which
filter does.

>
> Additionally, on this page there is no mention to FILTER (WHERE ...).
> Wouldn't it be better to explain something like it is on [2].
>

We already cross-reference to the authoritative sections for this. Could
entertain a rephrasing of those cross-references but I would not go and
make a big thing of it here. That said, maybe a separate “since all
aggregates accept a filter clause its syntax has been o tied here for
brevity” sentence would work and match up with the existing one for order
by.

David J.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message jian he 2026-02-21 15:07:52 Re: refactor ExecInitPartitionInfo
Previous Message Maxim Orlov 2026-02-21 14:59:21 Re: POC: make mxidoff 64 bits