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 1p8Cya-00087Y-Mp for pgsql-hackers@arkaria.postgresql.org; Thu, 22 Dec 2022 04:14:36 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1p8CyZ-000715-Eu for pgsql-hackers@arkaria.postgresql.org; Thu, 22 Dec 2022 04:14:35 +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 1p8CyZ-00070w-5s for pgsql-hackers@lists.postgresql.org; Thu, 22 Dec 2022 04:14:35 +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 1p8CyS-0006pK-Te for pgsql-hackers@lists.postgresql.org; Thu, 22 Dec 2022 04:14:34 +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 2BM4EQop1803396; Wed, 21 Dec 2022 23:14:26 -0500 From: Tom Lane To: Richard Guo cc: Andrey Lepikhov , PostgreSQL Hackers Subject: Re: Optimization issue of branching UNION ALL In-reply-to: <1800456.1671680935@sss.pgh.pa.us> References: <703c09a2-08f3-d2ec-b33d-dbecd62428b8@postgrespro.ru> <1788831.1671673839@sss.pgh.pa.us> <1800456.1671680935@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Wed, 21 Dec 2022 22:48:55 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1803394.1671682466.1@sss.pgh.pa.us> Date: Wed, 21 Dec 2022 23:14:26 -0500 Message-ID: <1803395.1671682466@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk I wrote: > Richard Guo writes: >> I noticed we also check 'parse->hasSubLinks' when we fix PHVs and >> AppendRelInfos in pull_up_simple_subquery. I'm not sure why we have >> this check. It seems not necessary. > Yeah, I was wondering about that too ... maybe it was important > in some previous state of the code? I didn't do any archeology > though. After a bit of "git blame"-ing, it appears that that hasSubLinks check was introduced in e006a24ad, which added a FlattenedSubLink node type and needed to fix them up here: + * We also have to fix the relid sets of any FlattenedSubLink nodes in + * the parent query. (This could perhaps be done by ResolveNew, but it Then when I got rid of FlattenedSubLink in e549722a8, I neglected to remove that check. So I think maybe we don't need it, but I've not tested. regards, tom lane