Re: custom average window function failure

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Sebastian P(dot) Luque" <spluque(at)gmail(dot)com>
Cc: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: custom average window function failure
Date: 2016-10-09 20:00:21
Message-ID: 12651.1476043221@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Sebastian P. Luque" <spluque(at)gmail(dot)com> writes:
> Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> On closer inspection, the error is only in the
>> aggregate-used-as-window-function case, not plain aggregation.

> Yes, I see the same phenomenon. Could someone suggest a workaround
> until this is fixed? I'm under the gun to submit output tables and the
> only thing I can think of is a crawling slow loop to step through each
> window twice: once using the plain aggregation and another without just
> get all rows. I highly doubt it will be worthwhile, given it's going to
> be about 1000 iterations, and each one would take about 30-45 min...

Are you in a position to apply patches? It's a one-line fix:
https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=dca25c2562199ce1e7e26367613912a8eadbbde8

Alternatively, the problem doesn't manifest when the aggregate transtype
and output type are the same, so you could probably refactor your code
to use plain array_agg and apply the finalfunc separately in the SQL
query.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2016-10-10 01:34:24 Re: custom average window function failure
Previous Message Sebastian P. Luque 2016-10-09 19:34:48 Re: custom average window function failure