Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1btQwY-0007Yl-IQ for pgsql-general@arkaria.postgresql.org; Mon, 10 Oct 2016 03:07:58 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1btQwY-0006qE-42 for pgsql-general@arkaria.postgresql.org; Mon, 10 Oct 2016 03:07:58 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1btQwX-0006p3-0W for pgsql-general@postgresql.org; Mon, 10 Oct 2016 03:07:57 +0000 Received: from [195.159.176.226] (helo=blaine.gmane.org) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1btQwQ-0005rH-8r for pgsql-general@postgresql.org; Mon, 10 Oct 2016 03:07:56 +0000 Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1btQw4-0001Tc-BQ for pgsql-general@postgresql.org; Mon, 10 Oct 2016 05:07:28 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-general@postgresql.org From: Sebastian P. Luque Subject: Re: custom average window function failure Date: Sun, 09 Oct 2016 22:10:22 -0500 Organization: Church of Emacs Lines: 29 Message-ID: <87a8ecvqzl.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> <12651.1476043221@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain X-Complaints-To: usenet@blaine.gmane.org User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) Cancel-Lock: sha1:RDk/wu4TEyRrLd8O2A+WIv+WI1Q= X-Host-Lookup-Failed: Reverse DNS lookup failed for 195.159.176.226 (failed) X-Pg-Spam-Score: -0.2 (/) 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 On Sun, 09 Oct 2016 16:00:21 -0400, Tom Lane wrote: > "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. Perfect, I'll try the latter option on this one. Thanks so much to both of you for your prompt feedback! -- Seb -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general