RE: Partial aggregates pushdown

From: "Fujii(dot)Yuki(at)df(dot)MitsubishiElectric(dot)co(dot)jp" <Fujii(dot)Yuki(at)df(dot)MitsubishiElectric(dot)co(dot)jp>
To: Jelte Fennema-Nio <postgres(at)jeltef(dot)nl>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, Bruce Momjian <bruce(at)momjian(dot)us>, Robert Haas <robertmhaas(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Stephen Frost <sfrost(at)snowman(dot)net>, Andres Freund <andres(at)anarazel(dot)de>, Tomas Vondra <tomas(dot)vondra(at)enterprisedb(dot)com>, Julien Rouhaud <rjuju123(at)gmail(dot)com>, Daniel Gustafsson <daniel(at)yesql(dot)se>, vignesh C <vignesh21(at)gmail(dot)com>, Alexander Pyhalov <a(dot)pyhalov(at)postgrespro(dot)ru>, "Fujii(dot)Yuki(at)df(dot)MitsubishiElectric(dot)co(dot)jp" <Fujii(dot)Yuki(at)df(dot)MitsubishiElectric(dot)co(dot)jp>
Subject: RE: Partial aggregates pushdown
Date: 2024-06-30 21:42:19
Message-ID: TY2PR01MB3835CB1D110362A3213E5F6795D22@TY2PR01MB3835.jpnprd01.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi hackers.

On Wed, Jun 5, 2024 at 9:15?AM Fujii(dot)Yuki(at)df(dot)MitsubishiElectric(dot)co(dot)jp <Fujii(dot)Yuki(at)df(dot)mitsubishielectric(dot)co(dot)jp> wrote:
> Requirement2. Consider appropriate position of the new keyword "PARTIAL_AGGREGATE". (with Robert)
> Existing patch: Before the target expression. Ex. avg(PARTIAL_AGGREGATE c1)
> Ideal: Before the aggregate function. Ex. PARTIAL_AGGREGATE avg(c1)
> Requirement3. Consider to avoid to make the new keyword "PARTIAL_AGGREGATE" become a reserved word. (with Robert)
> In the existing patch, "PARTIAL_AGGREGATE" is a reserved word.
I considered the above two requirement.
Based on my research, there is no way to use PARTIAL_AGGREGATE in front of a function name without making it a reserved word.

Instead, I can make PARTIAL_AGGREGATE an unreserved word by placing it after the FILTER clause, like avg(c1) FILTER (WHERE c2 > 0) PARTIAL_AGGREGATE, and by marking it as an ASLABEL word like FILTER.
I attached the patch of the method.
If there are no objections, I would like to proceed with the method described above.
I'd appreciate it if anyone comment the method.

I have addressed several comments, though not all of them.

On Mon, Jun 24, 2024 at 6:09?PM Jelte Fennema-Nio <postgres(at)jeltef(dot)nl> wrote:
> 4. Related to 3, I think it would be good to have some tests of
> PARTIAL_AGGREGATE that don't involve postgres_fdw at all. I also
> spotted some comments too that mention FDW, even though they apply to
> the "pure" PARTIAL_AGGREGATE code.
> 5. This comment now seems incorrect:
> - * Apply the agg's finalfn if one is provided, else return transValue.
> + * If the agg's finalfn is provided and PARTIAL_AGGREGATE keyword is
> + * not specified, apply the agg's finalfn.
> + * If PARTIAL_AGGREGATE keyword is specified and the transValue type
> + * is internal, apply the agg's serialfn. In this case the agg's
> + * serialfn must not be invalid. Otherwise return transValue.
>
> 6. These errors are not on purpose afaict (if they are a comment in
> the test would be good to explain why)
>
> +SELECT b, avg(a), max(a), count(*) FROM pagg_tab GROUP BY b ORDER BY 1;
> +ERROR: could not connect to server "loopback"
> +DETAIL: invalid connection option "partial_aggregate_support"
Fixed.

Best regards, Yuki Fujii
--
Yuki Fujii
Information Technology R&D Center, Mitsubishi Electric Corporation

Attachment Content-Type Size
0002-v2-POC-Partial-aggregate-pushdown-internal-transtype.patch application/octet-stream 63.7 KB
0001-v2-POC-Partial-aggregate-pushdown-notinternal-transtype.patch application/octet-stream 143.4 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Fujii.Yuki@df.MitsubishiElectric.co.jp 2024-06-30 22:07:26 RE: Partial aggregates pushdown
Previous Message Noah Misch 2024-06-30 21:08:17 Re: speed up a logical replica setup