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 1qIBjl-0005LO-JI for pgsql-hackers@arkaria.postgresql.org; Sat, 08 Jul 2023 17:28:49 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1qIBjk-0004u6-Ef for pgsql-hackers@arkaria.postgresql.org; Sat, 08 Jul 2023 17:28:48 +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 1qIBjk-0004tJ-5Q for pgsql-hackers@lists.postgresql.org; Sat, 08 Jul 2023 17:28:48 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qIBjh-002wsJ-Mv for pgsql-hackers@postgresql.org; Sat, 08 Jul 2023 17:28:47 +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 368HShfo1724689; Sat, 8 Jul 2023 13:28:43 -0400 From: Tom Lane To: Richard Guo cc: PostgreSQL-development Subject: Re: Check lateral references within PHVs for memoize cache keys In-reply-to: References: Comments: In-reply-to Richard Guo message dated "Tue, 04 Jul 2023 15:33:22 +0800" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1724687.1688837323.1@sss.pgh.pa.us> Date: Sat, 08 Jul 2023 13:28:43 -0400 Message-ID: <1724688.1688837323@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Richard Guo writes: > Rebase the patch on HEAD as cfbot reminds. This fix seems like a mess. The function that is in charge of filling RelOptInfo.lateral_vars is extract_lateral_references; or at least that was how it was done up to now. Can't we compute these additional references there? If not, maybe we ought to just merge extract_lateral_references into create_lateral_join_info, rather than having the responsibility split. I also wonder whether this change isn't creating hidden dependencies on RTE order (which would likely be bugs), since create_lateral_join_info itself examines the lateral_vars lists as it walks the rtable. More generally, it's not clear to me why we should need to look inside lateral PHVs in the first place. Wouldn't the lateral PHV itself serve fine as a cache key? regards, tom lane