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

Поиск
Список
Период
Сортировка
От Andriy Tkachuk
Тема IMMUTABLE function's flag do not work: 7.3.4, plpgsql
Дата
Msg-id 20031008152741.P17672-100000@pool.imt.com.ua
обсуждение исходный текст
Ответы Re: IMMUTABLE function's flag do not work: 7.3.4, plpgsql  (Tom Lane <tgl@sss.pgh.pa.us>)
Список 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@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


В списке pgsql-performance по дате отправления:

Предыдущее
От: Jeff
Дата:
Сообщение: Sun performance - Major discovery!
Следующее
От: Greg Spiegelberg
Дата:
Сообщение: Compare rows