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 1khHut-0008Q9-3Q for pgsql-hackers@arkaria.postgresql.org; Mon, 23 Nov 2020 19:54:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1khHur-0000Vl-CL for pgsql-hackers@arkaria.postgresql.org; Mon, 23 Nov 2020 19:54:25 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1khHur-0000Ve-5R for pgsql-hackers@lists.postgresql.org; Mon, 23 Nov 2020 19:54:25 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1khHuo-0002TT-Fu for pgsql-hackers@lists.postgresql.org; Mon, 23 Nov 2020 19:54: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 0ANJsKqS125708; Mon, 23 Nov 2020 14:54:20 -0500 From: Tom Lane To: Andrew Gierth cc: pgsql-hackers@lists.postgresql.org, kes-kes@yandex.ru Subject: Re: mark/restore failures on unsorted merge joins In-reply-to: <87o8jn50be.fsf@news-spur.riddles.org.uk> References: <87o8jn50be.fsf@news-spur.riddles.org.uk> Comments: In-reply-to Andrew Gierth message dated "Mon, 23 Nov 2020 19:48:29 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <125706.1606161260.1@sss.pgh.pa.us> Date: Mon, 23 Nov 2020 14:54:20 -0500 Message-ID: <125707.1606161260@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Andrew Gierth writes: > The problem is that the planner calls ExecSupportsMarkRestore to find > out whether a Materialize node is needed, and that function looks no > further than the Path type of T_Index[Only]Path in order to return true, > even though in this case it's a GiST index which does not support > mark/restore. > (Usually this can't be a problem because the merge join would need > sorted input, thus the index scan would be a btree; but a merge join > that doesn't actually have any sort keys could take unsorted input from > any index type.) Sounds like the right analysis. > Going forward, this looks like IndexOptInfo needs another am* boolean > field, but that's probably not appropriate for the back branches; maybe > as a workaround, ExecSupportsMarkRestore should just check for btree? Uh, why would you not just look to see if the ammarkpos/amrestrpos fields are non-null? regards, tom lane