Re: Partial Mode in Aggregate Functions - Mailing list pgsql-hackers

From David G. Johnston
Subject Re: Partial Mode in Aggregate Functions
Date
Msg-id CAKFQuwZVxp0EtiHfNiSvAZHBR6D9OCKpHa6fUk7tQqO9yRqdmQ@mail.gmail.com
Whole thread
In response to Re: Partial Mode in Aggregate Functions  (Marcos Pegoraro <marcos@f10.com.br>)
List pgsql-hackers
On Sun, Mar 1, 2026 at 7:55 AM Marcos Pegoraro <marcos@f10.com.br> wrote:
Em dom., 1 de mar. de 2026 às 11:29, David G. Johnston <david.g.johnston@gmail.com> escreveu:
I can’t come up with a better header than Partial Mode. 

The problem is that if they conclude that there is no FILTER for that aggregate, 
they decide to run two queries, not the most readable or the most performant one.
with Data as (select V from MyTable where F1 = 100)
select (select jsonb_agg(V) from Data) Total,
       (select jsonb_agg(V) from MyTable where V>1) Filtered;


I'm willing to entertain ideas, but for the proposed scenario I'm quite content to take the "not our problem" attitude here.  As you say, it's suboptimal, not wrong.  And it seems to me an unlikely real world outcome worth bending over backwards to accommodate based on theory alone.

I'm much more amenable to trying to make clear that FILTER exists, and in the process point out how/that it differs from Partial Mode.

David J.

pgsql-hackers by date:

Previous
From: Tomas Vondra
Date:
Subject: Re: index prefetching
Next
From: Sami Imseih
Date:
Subject: Re: pg_stat_statements: Add gc_count and query_file_size to pgss_info