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 1p8O4m-0001Qs-Nu for pgsql-hackers@arkaria.postgresql.org; Thu, 22 Dec 2022 16:05:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1p8O4l-00007J-Kq for pgsql-hackers@arkaria.postgresql.org; Thu, 22 Dec 2022 16:05:43 +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 1p8O4l-000056-CE for pgsql-hackers@lists.postgresql.org; Thu, 22 Dec 2022 16:05:43 +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 1p8O4g-0005rG-Ny for pgsql-hackers@lists.postgresql.org; Thu, 22 Dec 2022 16:05:41 +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 2BMG5aiq1961092; Thu, 22 Dec 2022 11:05:37 -0500 From: Tom Lane To: Andrey Lepikhov cc: PostgreSQL Hackers Subject: Re: Optimization issue of branching UNION ALL In-reply-to: <628db719-9c26-7aa3-540d-9b6d68e68da6@postgrespro.ru> References: <703c09a2-08f3-d2ec-b33d-dbecd62428b8@postgrespro.ru> <1788831.1671673839@sss.pgh.pa.us> <628db719-9c26-7aa3-540d-9b6d68e68da6@postgrespro.ru> Comments: In-reply-to Andrey Lepikhov message dated "Thu, 22 Dec 2022 16:59:41 +0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1961090.1671725136.1@sss.pgh.pa.us> Date: Thu, 22 Dec 2022 11:05:36 -0500 Message-ID: <1961091.1671725136@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Andrey Lepikhov writes: > Thanks, I have written the letter because of some doubts too. But only > one weak point I could imagine - if someday sql standard will be changed. Yeah, if they ever decide that LATERAL should be allowed to reference a previous sub-query of UNION ALL, that'd probably break this. But it'd break a lot of other code too, so I'm not going to worry about it. I pushed the main fix to HEAD only, and the recursion checks to all branches. regards, tom lane