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 1p8CZr-00053o-U2 for pgsql-hackers@arkaria.postgresql.org; Thu, 22 Dec 2022 03:49:03 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1p8CZp-0006Vv-ND for pgsql-hackers@arkaria.postgresql.org; Thu, 22 Dec 2022 03:49:01 +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 1p8CZp-0006Vl-EP for pgsql-hackers@lists.postgresql.org; Thu, 22 Dec 2022 03:49:01 +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 1p8CZn-0007Ye-5U for pgsql-hackers@lists.postgresql.org; Thu, 22 Dec 2022 03:49:01 +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 2BM3mtZ21800457; Wed, 21 Dec 2022 22:48:55 -0500 From: Tom Lane To: Richard Guo cc: Andrey Lepikhov , PostgreSQL Hackers Subject: Re: Optimization issue of branching UNION ALL In-reply-to: References: <703c09a2-08f3-d2ec-b33d-dbecd62428b8@postgrespro.ru> <1788831.1671673839@sss.pgh.pa.us> Comments: In-reply-to Richard Guo message dated "Thu, 22 Dec 2022 10:37:35 +0800" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1800455.1671680935.1@sss.pgh.pa.us> Date: Wed, 21 Dec 2022 22:48:55 -0500 Message-ID: <1800456.1671680935@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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. > In remove_result_refs, I don't think we need to check 'lastPHId' again > before calling substitute_phv_relids, since it has been checked a few > lines earlier. Oh, duh ... regards, tom lane