Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cU2jU-0000re-V6 for pgsql-performance@arkaria.postgresql.org; Thu, 19 Jan 2017 02:45:49 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cU2jU-0002cD-GK for pgsql-performance@arkaria.postgresql.org; Thu, 19 Jan 2017 02:45:48 +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_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cU2jT-0002bX-Dv for pgsql-performance@postgresql.org; Thu, 19 Jan 2017 02:45:47 +0000 Received: from vapor.isi.edu ([128.9.64.64]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cU2jN-0007eC-6v for pgsql-performance@postgresql.org; Thu, 19 Jan 2017 02:45:45 +0000 Received: from moraine.isi.edu (moraine.isi.edu [128.9.64.90]) by vapor.isi.edu (8.13.8/8.13.8) with ESMTP id v0J2jJpb006468; Wed, 18 Jan 2017 18:45:19 -0800 (PST) Date: Wed, 18 Jan 2017 18:45:12 -0800 From: Karl Czajkowski To: Tom Lane Cc: pgsql-performance@postgresql.org Subject: Re: optimizing immutable vs. stable function calls? Message-ID: <20170119024512.GE23081@moraine.isi.edu> References: <20170118223633.GC23081@moraine.isi.edu> <14964.1484780049@sss.pgh.pa.us> <20170118230646.GD23081@moraine.isi.edu> <16252.1484781941@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <16252.1484781941@sss.pgh.pa.us> X-ISI-4-43-8-MailScanner: Found to be clean X-MailScanner-From: karlcz@isi.edu X-Pg-Spam-Score: -10.1 (----------) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org On Jan 18, Tom Lane modulated: > Karl Czajkowski writes: > > Is there a correctness hazard with pretending our function is > > IMMUTABLE, even though we will change the underlying config parameter > > in the same connection? > > You could probably get away with that if you never ever use prepared > queries (beware that almost anything in plpgsql is a prepared query). > It's a trick that's likely to bite you eventually though. > That sounds unnerving. I think I need to play it safe. :-/ Does the plan cache disappear with each connection/backend process? Or is there also a risk of plans being shared between backends? Would it be invasive or a small hack to have something like "transaction-immutable" which can be precomputed during planning, like immutable, but then must discard those plans at the end of the transaction...? karl -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance