pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andriy Tkachuk <ant@imt.com.ua>
To: pgsql-performance@postgresql.org
Subject: IMMUTABLE function's flag do not work: 7.3.4, plpgsql
Date: Wed, 8 Oct 2003 16:16:52 +0300 (EEST)
Message-ID: <20031008152741.P17672-100000@pool.imt.com.ua> (raw)

Hi folks. I notice that immutable flag does nothing when i invoke
my plpgsql function within one session with same args.


tele=# SELECT version();
                           version
-------------------------------------------------------------
 PostgreSQL 7.3.4 on i686-pc-linux-gnu, compiled by GCC 2.96



At first EXPLAIN ANALYZE shown strange runtime :)

[15:41]/0:ant@monstr:~>time psql -c 'EXPLAIN ANALYZE SELECT calc_total(1466476, 1062363600, 1064955599)' tele
                                    QUERY PLAN
----------------------------------------------------------------------------------
 Result  (cost=0.00..0.01 rows=1 width=0) (actual time=0.00..0.00 rows=1 loops=1)
 Total runtime: 0.02 msec
                ^^^^^^^^^
(2 rows)

real    0m19.282s
        ^^^^^^^^^




At second. calc_total() is immutable function:

tele=# SELECT provolatile from pg_proc where proname = 'calc_total' and pronargs =3;
 provolatile
-------------
 i

but it seems that it's not cached in one session:

[15:38]/0:ant@monstr:~>psql tele
Welcome to psql 7.3.4, the PostgreSQL interactive terminal.

Type:  \copyright for distribution terms
       \h for help with SQL commands
       \? for help on internal slash commands
       \g or terminate with semicolon to execute query
       \q to quit

tele=# EXPLAIN ANALYZE SELECT calc_total(1466476, 1062363600, 1064955599);
                                    QUERY PLAN
----------------------------------------------------------------------------------
 Result  (cost=0.00..0.01 rows=1 width=0) (actual time=0.00..0.00 rows=1 loops=1)
 Total runtime: 0.02 msec
(2 rows)

tele=# EXPLAIN ANALYZE SELECT calc_total(1466476, 1062363600, 1064955599);
                                    QUERY PLAN
----------------------------------------------------------------------------------
 Result  (cost=0.00..0.01 rows=1 width=0) (actual time=0.00..0.00 rows=1 loops=1)
 Total runtime: 0.02 msec
(2 rows)


What i miss?

Thanks,
  Andriy Tkachuk

http://www.imt.com.ua




view thread (7+ messages)  latest in thread

Message-ID: <20031008152741.P17672-100000@pool.imt.com.ua>
Permalink:  ../20031008152741.P17672-100000@pool.imt.com.ua/
Also on:    postgresql.org/message-id/20031008152741.P17672-100000@pool.imt.com.ua

 · 

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-performance@postgresql.org
  Cc: ant@imt.com.ua
  Subject: Re: IMMUTABLE function's flag do not work: 7.3.4, plpgsql
  In-Reply-To: <20031008152741.P17672-100000@pool.imt.com.ua>
  References: <20031008152741.P17672-100000@pool.imt.com.ua>

* 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