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 1fpGcK-0003O6-C6 for pgsql-bugs@arkaria.postgresql.org; Mon, 13 Aug 2018 17:26:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fpGcI-0002dh-QV for pgsql-bugs@arkaria.postgresql.org; Mon, 13 Aug 2018 17:26:54 +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.89) (envelope-from ) id 1fpGcI-0002da-Kd for pgsql-bugs@lists.postgresql.org; Mon, 13 Aug 2018 17:26:54 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fpGcG-0003U8-0u for pgsql-bugs@lists.postgresql.org; Mon, 13 Aug 2018 17:26:54 +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 w7DHQjQT021039; Mon, 13 Aug 2018 13:26:45 -0400 From: Tom Lane To: Marko Tiikkaja cc: Andres Freund , andy@prestigedigital.com, pgsql-bugs@lists.postgresql.org 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> Comments: In-reply-to Marko Tiikkaja message dated "Mon, 13 Aug 2018 19:43:27 +0300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <21037.1534181205.1@sss.pgh.pa.us> Date: Mon, 13 Aug 2018 13:26:45 -0400 Message-ID: <21038.1534181205@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Marko Tiikkaja writes: > On Mon, Aug 13, 2018 at 7:35 PM, Andres Freund wrote: >> Well, the subselect with thelimit going to return different results from >> run to run. Unless you add an ORDER BY there's no guaranteed order in >> which tuples are returned. So I don't think it's surprising that you're >> getting results that differ between runs. > While this is true, that's missing the point. Yeah, I agree. I think probably what's happening is that the sub-select is getting pushed down to the parallel workers and they are not all computing the same set of sub-select results, leading to inconsistent answers at the top level. Likely, we need to treat the presence of a LIMIT/OFFSET in a sub-select as making it parallel-unsafe, for exactly the reason that that makes its results non-deterministic. regards, tom lane