Re: Partial aggregates pushdown

From: Alexander Pyhalov <a(dot)pyhalov(at)postgrespro(dot)ru>
To: "Fujii(dot)Yuki(at)df(dot)MitsubishiElectric(dot)co(dot)jp" <Fujii(dot)Yuki(at)df(dot)mitsubishielectric(dot)co(dot)jp>
Cc: Tomas Vondra <tomas(dot)vondra(at)enterprisedb(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, Andres Freund <andres(at)anarazel(dot)de>, Julien Rouhaud <rjuju123(at)gmail(dot)com>, Daniel Gustafsson <daniel(at)yesql(dot)se>, Ilya Gladyshev <i(dot)gladyshev(at)postgrespro(dot)ru>
Subject: Re: Partial aggregates pushdown
Date: 2022-11-30 13:30:24
Message-ID: 4c02341e5e1b10f35c7b3dfbc73084f0@postgrespro.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Fujii(dot)Yuki(at)df(dot)MitsubishiElectric(dot)co(dot)jp писал 2022-11-30 13:01:
> Hi Mr.Pyhalov.
>
>> 1) In previous version of the patch aggregates, which had
>> partialaggfn, were ok
>> to push down. And it was a definite sign that aggregate can be pushed
>> down.
>> Now we allow pushing down an aggregate, which prorettype is not
>> internal and
>> aggfinalfn is not defined. Is it safe for all user-defined (or
>> builtin) aggregates,
>> even if they are generally shippable? Aggcombinefn is executed locally
>> and we
>> check that aggregate function itself is shippable. Is it enough?
>> Perhaps, we
>> could use partialagg_minversion (like aggregates with
>> partialagg_minversion
>> == -1 should not be pushed down) or introduce separate explicit flag?
> In what case partial aggregate pushdown is unsafe for aggregate which
> has not internal aggtranstype
> and has no aggfinalfn?
> By reading [1], I believe that if aggcombinefn of such aggregate
> recieves return values of original
> aggregate functions in each remote then it must produce same value
> that would have resulted
> from scanning all the input in a single operation.
>

One more issue I started to think about - now we don't check
partialagg_minversion for "simple" aggregates at all. Is it correct? It
seems that , for example, we could try to pushdown bit_or(int8) to old
servers, but it didn't exist, for example, in 8.4. I think it's a
broader issue (it would be also the case already if we push down
aggregates) and shouldn't be fixed here. But there is an issue -
is_shippable() is too optimistic.

--
Best regards,
Alexander Pyhalov,
Postgres Professional

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2022-11-30 13:39:23 Re: pgsql: Revoke PUBLIC CREATE from public schema, now owned by pg_databas
Previous Message Ian Lawrence Barwick 2022-11-30 12:56:29 Re: daitch_mokotoff module