Re: Partial aggregates pushdown

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Jelte Fennema-Nio <postgres(at)jeltef(dot)nl>
Cc: "Fujii(dot)Yuki(at)df(dot)MitsubishiElectric(dot)co(dot)jp" <Fujii(dot)Yuki(at)df(dot)mitsubishielectric(dot)co(dot)jp>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, 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>
Subject: Re: Partial aggregates pushdown
Date: 2024-08-20 16:50:37
Message-ID: ZsTJXZq2pcx1Pst-@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Aug 20, 2024 at 10:07:32AM +0200, Jelte Fennema-Nio wrote:
> On Thu, 15 Aug 2024 at 23:12, Bruce Momjian <bruce(at)momjian(dot)us> wrote:
> > Third, I would like to show a more specific example to clarify what is
> > being considered above. If we look at MAX(), we can have FDWs return
> > the max for each FDW, and the coordinator can chose the highest value.
> > This is the patch 1 listed above. These can return the
> > pg_aggregate.aggtranstype data type using the pg_type.typoutput text
> > output.
> >
> > The second case is for something like AVG(), which must return the SUM()
> > and COUNT(), and we currently have no way to return multiple text values
> > on the wire. For patch 0002, we have the option of creating functions
> > that can do this and record them in new pg_attribute columns, or we can
> > create a data type with these functions, and assign the data type to
> > pg_aggregate.aggtranstype.
> >
> > Is that accurate?
>
> It's close to accurate, but not entirely. Patch 1 would actually
> solves some AVG cases too, because some AVG implementations use an SQL
> array type to store the transtype instead of an internal type. And by
> using an SQL array type we *can* send multiple text values on the
> wire. See below for a list of those aggregates:

Okay, so we can do MAX easily, and AVG if the count can be represented
as the same data type as the sum? Is that correct? Our only problem is
that something like AVG(interval) can't use an array because arrays have
to have the same data type for all array elements, and an interval can't
represent a count?

--
Bruce Momjian <bruce(at)momjian(dot)us> https://momjian.us
EDB https://enterprisedb.com

Only you can decide what is important to you.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2024-08-20 16:55:31 Re: Some questions about PostgreSQL’s design.
Previous Message Yugo Nagata 2024-08-20 16:49:20 Re: [Bug Fix]standby may crash when switching-over in certain special cases