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 1hr593-00025q-Ka for pgsql-hackers@arkaria.postgresql.org; Fri, 26 Jul 2019 18:40: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 1hr592-00012x-2H for pgsql-hackers@arkaria.postgresql.org; Fri, 26 Jul 2019 18:40:44 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hr591-0000uB-L2 for pgsql-hackers@lists.postgresql.org; Fri, 26 Jul 2019 18:40:43 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1hr58u-0002g6-Fm for pgsql-hackers@lists.postgresql.org; Fri, 26 Jul 2019 18:40:41 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id x6QIeZb8019454; Fri, 26 Jul 2019 14:40:35 -0400 From: Tom Lane To: Anastasia Lubennikova cc: pgsql-hackers@lists.postgresql.org Subject: Re: Optimze usage of immutable functions as relation In-reply-to: <18924.1564165560@sss.pgh.pa.us> References: <402356c32eeb93d4fed01f66d6c7fe2d@postgrespro.ru> <20180906185109.661aaef0@asp437-ThinkPad-L380> <153994199621.10161.17815885396545049364.pgcf@coridan.postgresql.org> <2906.1542395026@sss.pgh.pa.us> <3f7fda2f-1cdc-8ad3-e3c9-c2436fb5d509@postgrespro.ru> <0dd4efb2-22a3-6fef-11f7-1b20dd71a509@postgrespro.ru> <18924.1564165560@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Fri, 26 Jul 2019 14:26:00 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <19452.1564166435.1@sss.pgh.pa.us> Date: Fri, 26 Jul 2019 14:40:35 -0400 Message-ID: <19453.1564166435@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk I wrote: > * It would be useful for the commentary to point out that in principle we > could pull up any immutable (or, probably, even just stable) expression; > but we don't, (a) for fear of multiple evaluations of the result costing > us more than we can save, and (b) because a primary goal is to let the > constant participate in further const-folding, and of course that won't > happen for a non-Const. BTW, so far as I can see, none of the test cases demonstrate that such further const-folding can happen. Since this is all pretty processing- order-sensitive, I think an explicit test that that's possible would be a good idea. regards, tom lane