Re: FDW RTE join pushdown fails to create plan with aggregates

From: Kirill Reshke <reshkekirill(at)gmail(dot)com>
To: Alexander Pyhalov <a(dot)pyhalov(at)postgrespro(dot)ru>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Alexander Korotkov <aekorotkov(at)gmail(dot)com>
Subject: Re: FDW RTE join pushdown fails to create plan with aggregates
Date: 2026-09-25 08:22:19
Message-ID: CALdSSPiXyFU=F42hG5CodkEdAsBezscRNT5iiJQ+h8_Oo8_MrQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, 25 Sept 2026 at 12:20, Alexander Pyhalov
<a(dot)pyhalov(at)postgrespro(dot)ru> wrote:
>
>
> Hi.
>
> Yes, there's an issue, but it seems to be not specific to function
> pushdown.
> For example, the following test case
>
> EXPLAIN (VERBOSE, COSTS OFF)
> SELECT count(1) FROM remote_tbl r1, remote_tbl r2 GROUP BY r1.a;
> ERROR: Aggref found where not expected

Hmm, very interesting, before report I checked on 0ee83dd4a99 and for
me it differs:

reshke=# explain
SELECT count(1) FROM rmt.a a, rmt.a b GROUP BY a.id
;
QUERY PLAN
--------------------------------------------------------------------------------
Finalize GroupAggregate (cost=200.00..13594.87 rows=200 width=12)
Group Key: a.id
-> Nested Loop (cost=200.00..10179.87 rows=682600 width=12)
-> Partial GroupAggregate (cost=100.00..777.98 rows=200 width=12)
Group Key: a.id
-> Foreign Scan on a (cost=100.00..761.35 rows=2925 width=4)
-> Materialize (cost=100.00..877.93 rows=3413 width=0)
-> Foreign Scan on a b (cost=100.00..860.86 rows=3413 width=0)
(8 rows)

reshke=# explain
SELECT count(1) FROM rmt.a, generate_series(1,1) GROUP BY id
;
ERROR: Aggref found in non-Agg plan node

With 0ee83dd4a99~1 (e13851080c) both queries run OK

> I'm not sure, does issue affect only joinrels? Can't we encounter other
grouped rels while building foreign paths?

I didn't manage to get any exposure other than join-grouped rels.

--
Best regards,
Kirill Reshke

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message torikoshia 2026-09-25 08:25:34 Re: RFC: Allow EXPLAIN to Output Page Fault Information
Previous Message Amit Langote 2026-09-25 08:16:06 Re: RI fastpath misses checking EXECUTE on functions