Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mXZ94-0006iP-PE for pgsql-bugs@arkaria.postgresql.org; Tue, 05 Oct 2021 01:21:26 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mXZ93-00066C-NQ for pgsql-bugs@arkaria.postgresql.org; Tue, 05 Oct 2021 01:21:25 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mXZ93-000664-Gt for pgsql-bugs@lists.postgresql.org; Tue, 05 Oct 2021 01:21:25 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mXZ91-0005NB-EQ for pgsql-bugs@lists.postgresql.org; Tue, 05 Oct 2021 01:21:24 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 1951LLJe4022670; Mon, 4 Oct 2021 21:21:21 -0400 From: Tom Lane To: Elvis Pranskevichus cc: PostgreSQL mailing lists , David Rowley Subject: Re: BUG #17213: Wrong result from a query involving Merge Semi Join and Memoize In-reply-to: <4374396.LvFx2qVVIh@vulcan.edgedb.net> References: <17213-988ed34b225a2862@postgresql.org> <4374396.LvFx2qVVIh@vulcan.edgedb.net> Comments: In-reply-to Elvis Pranskevichus message dated "Mon, 04 Oct 2021 17:36:09 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <4022668.1633396881.1@sss.pgh.pa.us> Date: Mon, 04 Oct 2021 21:21:21 -0400 Message-ID: <4022669.1633396881@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Elvis Pranskevichus writes: > On Monday, October 4, 2021 5:14:47 PM PDT David Rowley wrote: >>> It appears a combination of Merge Semi Join and Memoize in >>> PostgreSQL 14 produces incorrect results on a particular query. > It seems like a very particular set of stats is causing the plan there, > as running ANALYZE turns the query into a Nested Loop Semi Join. Surely this plan tree is broken on its face? The inner side of a mergejoin has to be able to support mark/restore, and nestloop doesn't (cf ExecSupportsMarkRestore, as well as assertions in nodeNestloop). It looks to me like somebody removed an essential plan-time check. regards, tom lane