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:[EMAIL PROTECTED]:~>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:[EMAIL PROTECTED]:~>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 ---------------------------(end of broadcast)--------------------------- TIP 9: the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match