Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fpbUd-0007jG-EO for pgsql-bugs@arkaria.postgresql.org; Tue, 14 Aug 2018 15:44:23 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fpbUZ-0003Ra-Kq for pgsql-bugs@arkaria.postgresql.org; Tue, 14 Aug 2018 15:44:19 +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.89) (envelope-from ) id 1fpbUZ-0003RG-BB for pgsql-bugs@lists.postgresql.org; Tue, 14 Aug 2018 15:44:19 +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.89) (envelope-from ) id 1fpbUW-0004p1-9y for pgsql-bugs@lists.postgresql.org; Tue, 14 Aug 2018 15:44:17 +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 w7EFiAAW000391; Tue, 14 Aug 2018 11:44:10 -0400 From: Tom Lane To: Marko Tiikkaja cc: Amit Kapila , Andres Freund , Andrew Fletcher , PostgreSQL mailing lists Subject: Re: BUG #15324: Non-deterministic behaviour from parallelised sub-query In-reply-to: References: <153417684333.10284.11356259990921828616@wrigleys.postgresql.org> <20180813163518.gqvu2kqwr6uj75vj@alap3.anarazel.de> <21038.1534181205@sss.pgh.pa.us> Comments: In-reply-to Marko Tiikkaja message dated "Tue, 14 Aug 2018 15:20:41 +0300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <389.1534261450.1@sss.pgh.pa.us> Date: Tue, 14 Aug 2018 11:44:10 -0400 Message-ID: <390.1534261450@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Marko Tiikkaja writes: > Marking the function parallel safe doesn't seem wrong to me. The > non-parallel-safe part is that the input gets fed to it in different order > in different workers. And I don't really think that to be the function's > fault. So that basically opens the question of whether *any* window function calculation can safely be pushed down to parallel workers. Somewhat like the LIMIT/OFFSET case, it seems to me that we could only expect to do this safely if the row ordering induced by the WINDOW clause can be proven to be fully deterministic. The planner has no such smarts at the moment AFAIR. In principle you could do it if there were partitioning/ordering by a primary key, but I'm not excited about the prospects of that being true often enough in practice to justify making the check. regards, tom lane