Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1btKGu-0000yp-HI for pgsql-general@arkaria.postgresql.org; Sun, 09 Oct 2016 20:00:32 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1btKGt-0006c8-Vo for pgsql-general@arkaria.postgresql.org; Sun, 09 Oct 2016 20:00:32 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1btKGt-0006c1-AD for pgsql-general@postgresql.org; Sun, 09 Oct 2016 20:00:31 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1btKGm-0005K5-7Z for pgsql-general@postgresql.org; Sun, 09 Oct 2016 20:00:30 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id u99K0LjN012652; Sun, 9 Oct 2016 16:00:21 -0400 From: Tom Lane To: "Sebastian P. Luque" cc: Adrian Klaver , pgsql-general@postgresql.org Subject: Re: custom average window function failure In-reply-to: <87eg3puxif.fsf@otaria.sebmel.org> References: <87int2qkat.fsf@gmail.com> <19183.1476027964@sss.pgh.pa.us> <1156e81d-0903-f453-6751-347d5105d4ca@aklaver.com> <4302.1476031209@sss.pgh.pa.us> <87eg3puxif.fsf@otaria.sebmel.org> Comments: In-reply-to "Sebastian P. Luque" message dated "Sun, 09 Oct 2016 14:34:48 -0500" Date: Sun, 09 Oct 2016 16:00:21 -0400 Message-ID: <12651.1476043221@sss.pgh.pa.us> X-Pg-Spam-Score: -4.6 (----) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-general Precedence: bulk Sender: pgsql-general-owner@postgresql.org "Sebastian P. Luque" writes: > Tom Lane 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 -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general