Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hVFNp-0000yr-CG for pgsql-bugs@arkaria.postgresql.org; Mon, 27 May 2019 13:09:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hVFNn-0006VN-HY for pgsql-bugs@arkaria.postgresql.org; Mon, 27 May 2019 13:09:43 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hVFNn-0006Rf-8X for pgsql-bugs@lists.postgresql.org; Mon, 27 May 2019 13:09:43 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hVFNg-0006Ju-R9 for pgsql-bugs@lists.postgresql.org; Mon, 27 May 2019 13:09:42 +0000 Received: from pro.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id x4RD9YgY014375; Mon, 27 May 2019 09:09:34 -0400 From: Tom Lane To: luis.carril@swarm64.com cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #15820: Commuting two column make a SubqueryScan node to appear in the plan In-reply-to: <15820-adc0b2f210dc1d49@postgresql.org> References: <15820-adc0b2f210dc1d49@postgresql.org> Comments: In-reply-to PG Bug reporting form message dated "Mon, 27 May 2019 12:54:27 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <65154.1558962574.1@sss.pgh.pa.us> Date: Mon, 27 May 2019 09:09:34 -0400 Message-ID: <65155.1558962574@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk PG Bug reporting form writes: > switching the order of two columns make a SubqueryScan node to appear in > the plan. It seems completely trivial as the cost is not modified, should it > also be removed in the second case? No. The SubqueryScan can only be optimized away if it makes no changes in the result tuple. Conceivably, with sufficiently complicated hacking in setrefs.c, simple cases like column reordering could be handled there. But I'm doubtful that it's worth the added cycles & risk of bugs. regards, tom lane