pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Gaetano Mendola <mendola@bigfoot.com>
To: pgsql-admin@postgresql.org
Subject: Re: Strange behaviour ( function cachable )
Date: Thu, 19 Dec 2002 09:59:18 +0100
Message-ID: <ats1p5$1m8b$1@news.hub.org> (raw)
References: <11105.1040238975@sss.pgh.pa.us>


"Tom Lane" <tgl@sss.pgh.pa.us> wrote in message
news:11105.1040238975@sss.pgh.pa.us...
> "Gaetano Mendola" <mendola@bigfoot.com> 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








view thread (3+ messages)

Message-ID: <ats1p5$1m8b$1@news.hub.org>
Permalink:  ../ats1p5$1m8b$1@news.hub.org/
Also on:    postgresql.org/message-id/ats1p5$1m8b$1@news.hub.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: mendola@bigfoot.com
  Subject: Re: Strange behaviour ( function cachable )
  In-Reply-To: <ats1p5$1m8b$1@news.hub.org>
  References: <11105.1040238975@sss.pgh.pa.us> <ats1p5$1m8b$1@news.hub.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox