IMMUTABLE function's flag do not work: 7.3.4, plpgsql

From: Andriy Tkachuk <ant(at)imt(dot)com(dot)ua>
To: pgsql-performance(at)postgresql(dot)org
Subject: IMMUTABLE function's flag do not work: 7.3.4, plpgsql
Date: 2003-10-08 13:16:52
Message-ID: 20031008152741.P17672-100000@pool.imt.com.ua
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

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(at)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(at)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

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Greg Spiegelberg 2003-10-08 14:07:36 Compare rows
Previous Message Jeff 2003-10-08 12:36:56 Sun performance - Major discovery!