Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 5D2AC475CC7 for ; Thu, 19 Dec 2002 03:59:18 -0500 (EST) Received: from news.hub.org (news.hub.org [64.49.215.80]) by postgresql.org (Postfix) with ESMTP id EA999474E61 for ; Thu, 19 Dec 2002 03:59:17 -0500 (EST) Received: by news.hub.org (Postfix, from userid 8) id BE9C943A75D; Thu, 19 Dec 2002 03:59:17 -0500 (EST) From: "Gaetano Mendola" X-Newsgroups: comp.databases.postgresql.admin Subject: Re: Strange behaviour ( function cachable ) Date: Thu, 19 Dec 2002 09:59:18 +0100 Organization: Hub.Org Networking Services (http://www.hub.org) Lines: 62 Message-ID: References: <11105.1040238975@sss.pgh.pa.us> X-Complaints-To: usenet@news.hub.org X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 To: pgsql-admin@postgresql.org X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200212/241 X-Sequence-Number: 6736 "Tom Lane" wrote in message news:11105.1040238975@sss.pgh.pa.us... > "Gaetano Mendola" writes: > > I expected that if a function is cachable and is used > > inside a select like: > > SELECT * FROM foo WHERE id = my_func( a_param ) > > then the function my_func is called one for each different value > > of a_param. > > That is not what "cachable" means to Postgres. There is no function > result cache such as you seem to envision. > > regards, tom lane Just to understand, do you mean that the following behaviour is correct? # create table test( a int, b int ); CREATE # insert into test values (1,2); INSERT 79298997 1 # insert into test values (1,2); INSERT 79298998 1 # insert into test values (1,2); INSERT 79298999 1 #select * from test where a = sp_cache( 3 ); NOTICE: CALLED a | b ---+--- (0 rows) #select sp_test ( 4); NOTICE: CALLED NOTICE: CALLED NOTICE: CALLED sp_test --------- (1 row) where sp_cache is a function declared ( iscachable ) and do a notice each time that is called and sp_test is a function that perform: "select * from test where a = sp_cache( 3 )" How you can see in the first case I see only a NOTICE in the second case I see 3 NOTICE, why ? Am I wrong ? Ciao Gaetano