Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tZC2y-003DvB-Qd for pgsql-bugs@arkaria.postgresql.org; Sat, 18 Jan 2025 16:51:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tZC2x-001PAu-9G for pgsql-bugs@arkaria.postgresql.org; Sat, 18 Jan 2025 16:51:43 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tZC2x-001PAc-15 for pgsql-bugs@lists.postgresql.org; Sat, 18 Jan 2025 16:51:43 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tZC2u-000DlI-1T for pgsql-bugs@lists.postgresql.org; Sat, 18 Jan 2025 16:51:43 +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 50IGpbcR2550570; Sat, 18 Jan 2025 11:51:37 -0500 From: Tom Lane To: Zhang Mingli cc: exclusion@gmail.com, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #18778: Query planning fails in ExecInitExprRec with unrecognized node type In-reply-to: References: <18778-24cd399df6c806af@postgresql.org> <1919554.1737070534@sss.pgh.pa.us> Comments: In-reply-to Zhang Mingli message dated "Sat, 18 Jan 2025 23:52:01 +0800" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2550568.1737219097.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Sat, 18 Jan 2025 11:51:37 -0500 Message-ID: <2550569.1737219097@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Zhang Mingli writes: > And I have a question that may not be directly related to the issue: why= is there a Subplan 2, and it appears to be unused? Yeah, that's because the AlternativeSubPlan originally had two child subplans: a parameterized one intended for a few calls, and a hashed one to be used for a lot of calls. We build both because at the time when this needs to happen, we don't have any clue how many calls there will be. We wait till the very end of planning to decide which one is more likely to win based on context, and then discard the AlternativeSubPlan, replacing it with a direct reference to the chosen SubPlan. But the other one stays in the tree. Getting rid of it seemed complicated, and it won't be referenced at runtime so there's not much penalty from leaving it there. It is confusing, I admit. regards, tom lane