From postgres@kiwi-fraser.net Thu Jun 23 13:26:34 2005 X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id A67C75293D for ; Thu, 23 Jun 2005 10:26:34 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 41326-09 for ; Thu, 23 Jun 2005 13:26:30 +0000 (GMT) Received: from CISX-Linux4.cisx.com (unknown [213.133.202.58]) by svr1.postgresql.org (Postfix) with ESMTP id 173BB52933 for ; Thu, 23 Jun 2005 10:26:23 -0300 (ADT) Received: from DonAcer ([192.168.100.99]) by CISX-Linux4.cisx.com (8.12.8/8.12.8) with SMTP id j5NDQP1L032612 for ; Thu, 23 Jun 2005 14:26:26 +0100 Message-ID: <002301c577f7$28141780$6364a8c0@DonAcer> From: "Donald Fraser" To: "[ADMIN]" Subject: Are cached IMMUTABLE values persistent between sessions Date: Thu, 23 Jun 2005 14:26:23 +0100 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0020_01C577FF.88519160" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.2180 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.078 tagged_above=0 required=5 tests=FORGED_RCVD_HELO, HTML_60_70, HTML_MESSAGE X-Spam-Level: X-Archive-Number: 200506/168 X-Sequence-Number: 17923 This is a multi-part message in MIME format. ------=_NextPart_000_0020_01C577FF.88519160 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Is the returned value of a function defined as IMMUTABLE cached = globally? In other words could postgresql potentially return a cached = value obtained from one client session to a different client session? Thanks in advance Donald Fraser ------=_NextPart_000_0020_01C577FF.88519160 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Is the returned value of a = function defined as=20 IMMUTABLE cached globally? In other words could postgresql = potentially=20 return a cached value obtained from one client session to a = different=20 client session?
 
Thanks in advance
Donald = Fraser 
------=_NextPart_000_0020_01C577FF.88519160-- From tgl@sss.pgh.pa.us Thu Jun 23 14:33:11 2005 X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id ABA5152933 for ; Thu, 23 Jun 2005 11:33:11 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 50444-09 for ; Thu, 23 Jun 2005 14:33:06 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id AA85852949 for ; Thu, 23 Jun 2005 11:33:05 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j5NEX3vJ004918; Thu, 23 Jun 2005 10:33:03 -0400 (EDT) To: "Donald Fraser" Cc: "[ADMIN]" Subject: Re: Are cached IMMUTABLE values persistent between sessions In-reply-to: <002301c577f7$28141780$6364a8c0@DonAcer> References: <002301c577f7$28141780$6364a8c0@DonAcer> Comments: In-reply-to "Donald Fraser" message dated "Thu, 23 Jun 2005 14:26:23 +0100" Date: Thu, 23 Jun 2005 10:33:03 -0400 Message-ID: <4917.1119537183@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200506/170 X-Sequence-Number: 17925 "Donald Fraser" writes: > Is the returned value of a function defined as IMMUTABLE cached = > globally? No, in fact it isn't cached at all. IMMUTABLE tells the planner that it's OK to fold a function call with constant inputs to a constant result value at plan time. Nothing more. regards, tom lane From alvherre@surnet.cl Thu Jun 23 14:41:15 2005 X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 4C6F252939 for ; Thu, 23 Jun 2005 11:41:15 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 53223-10 for ; Thu, 23 Jun 2005 14:41:10 +0000 (GMT) Received: from mr2.surnet.cl (smtp2.surnet.cl [216.155.73.163]) by svr1.postgresql.org (Postfix) with ESMTP id 926C55293C for ; Thu, 23 Jun 2005 11:41:10 -0300 (ADT) Received: from smtp2.surnet.cl (216.155.73.169) by mr2.surnet.cl (7.0.031.3) id 4259ADFA01078F2F; Thu, 23 Jun 2005 10:40:57 -0400 Received: from smtp2.surnet.cl (mr2.surnet.cl []) by mr2.surnet.cl ([216.155.73.169]); Thu, 23 Jun 2005 14:40:57 +0000 Received: from cluster.surnet.cl (216.155.73.164) by smtp2.surnet.cl (7.0.031.3) id 4259ADE3009D39E7; Thu, 23 Jun 2005 10:40:56 -0400 Received: from localhost (200.85.219.179) by cluster.surnet.cl (7.0.043) id 42B3EF60000BACE8; Thu, 23 Jun 2005 10:40:54 -0400 Received: by localhost (Postfix, from userid 1000) id 32B0DC2956C; Thu, 23 Jun 2005 10:40:55 -0400 (CLT) Date: Thu, 23 Jun 2005 10:40:55 -0400 From: Alvaro Herrera To: Donald Fraser Cc: "[ADMIN]" Subject: Re: Are cached IMMUTABLE values persistent between sessions Message-ID: <20050623144055.GC7656@surnet.cl> References: <002301c577f7$28141780$6364a8c0@DonAcer> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <002301c577f7$28141780$6364a8c0@DonAcer> User-Agent: Mutt/1.5.9i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.584 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE, DNS_FROM_RFC_POST, FORGED_RCVD_HELO X-Spam-Level: * X-Archive-Number: 200506/169 X-Sequence-Number: 17924 On Thu, Jun 23, 2005 at 02:26:23PM +0100, Donald Fraser wrote: > Is the returned value of a function defined as IMMUTABLE cached > globally? In other words could postgresql potentially return a cached > value obtained from one client session to a different client session? Return values from functions are never cached at all, not even for immutable functions. The mutability flag (currently) is only used for deciding the "optimizability" of the function within the query's execution. -- Alvaro Herrera () "El que vive para el futuro es un iluso, y el que vive para el pasado, un imbécil" (Luis Adler, "Los tripulantes de la noche") From mike@fuhr.org Thu Jun 23 15:00:43 2005 X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id CD52B52934 for ; Thu, 23 Jun 2005 12:00:43 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 60557-07 for ; Thu, 23 Jun 2005 15:00:37 +0000 (GMT) Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) by svr1.postgresql.org (Postfix) with ESMTP id 571E95285C for ; Thu, 23 Jun 2005 12:00:35 -0300 (ADT) Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) by tigger.fuhr.org (8.13.3/8.13.3) with ESMTP id j5NF0O3d078386 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 23 Jun 2005 09:00:27 -0600 (MDT) (envelope-from mfuhr@winnie.fuhr.org) Received: from winnie.fuhr.org (localhost [127.0.0.1]) by winnie.fuhr.org (8.13.3/8.13.3) with ESMTP id j5NF0NqQ036842; Thu, 23 Jun 2005 09:00:23 -0600 (MDT) (envelope-from mfuhr@winnie.fuhr.org) Received: (from mfuhr@localhost) by winnie.fuhr.org (8.13.3/8.13.3/Submit) id j5NF0NXH036841; Thu, 23 Jun 2005 09:00:23 -0600 (MDT) (envelope-from mfuhr) Date: Thu, 23 Jun 2005 09:00:23 -0600 From: Michael Fuhr To: Donald Fraser Cc: "[ADMIN]" Subject: Re: Are cached IMMUTABLE values persistent between sessions Message-ID: <20050623150023.GA36745@winnie.fuhr.org> References: <002301c577f7$28141780$6364a8c0@DonAcer> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <002301c577f7$28141780$6364a8c0@DonAcer> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.005 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200506/171 X-Sequence-Number: 17926 On Thu, Jun 23, 2005 at 02:26:23PM +0100, Donald Fraser wrote: > > Is the returned value of a function defined as IMMUTABLE cached > globally? In other words could postgresql potentially return a > cached value obtained from one client session to a different client > session? You could experiment with this by adding a debugging RAISE statement to an IMMUTABLE PL/pgSQL function to see when it's called. I suspect there's no global caching; if there is then I haven't been able to make it happen in tests. There doesn't even appear to be any caching between disparate queries in the same session unless a prepared plan is involved (e.g., a plan made with PREPARE or a cached plan from a PL/pgSQL function) and the result of the IMMUTABLE function could be determined at planning time. -- Michael Fuhr http://www.fuhr.org/~mfuhr/ From postgres@kiwi-fraser.net Fri Jun 24 09:53:55 2005 X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id E6FDE528BB for ; Fri, 24 Jun 2005 06:53:55 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 00333-10 for ; Fri, 24 Jun 2005 09:53:49 +0000 (GMT) Received: from CISX-Linux4.cisx.com (unknown [213.133.202.58]) by svr1.postgresql.org (Postfix) with ESMTP id BEA6A528D9 for ; Fri, 24 Jun 2005 06:53:44 -0300 (ADT) Received: from DonAcer ([192.168.100.99]) by CISX-Linux4.cisx.com (8.12.8/8.12.8) with SMTP id j5O9rj1L003154 for ; Fri, 24 Jun 2005 10:53:46 +0100 Message-ID: <004801c578a2$9cfeb360$6364a8c0@DonAcer> From: "Donald Fraser" To: "[ADMIN]" References: <002301c577f7$28141780$6364a8c0@DonAcer> <4917.1119537183@sss.pgh.pa.us> Subject: Re: Are cached IMMUTABLE values persistent between sessions Date: Fri, 24 Jun 2005 10:53:44 +0100 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.2180 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.056 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200506/190 X-Sequence-Number: 17945 > "Donald Fraser" writes: >> Is the returned value of a function defined as IMMUTABLE cached = >> globally? "Tom Lane" writes: > No, in fact it isn't cached at all. IMMUTABLE tells the planner that > it's OK to fold a function call with constant inputs to a constant > result value at plan time. Nothing more. Ok I'm sort of clutching at straws here... What about this scenario: I'm aware that sql statements within PL/pgSQL functions get cached. Therefore if the query planner can fold a function with a constant result, could that query plan get cached by PL/pgSQL with a folded value? Regards Donald Fraser