Postgres optimizer, repeated function calls

Поиск
Список
Период
Сортировка
От Sergey E. Koposov
Тема Postgres optimizer, repeated function calls
Дата
Msg-id Pine.LNX.4.44.0509051853200.15334-100000@lnfm1.sai.msu.ru
обсуждение исходный текст
Список pgsql-hackers
Hello, 

I have the following question about the Postgres optimizer.

I have two functions: 

CREATE OR REPLACE FUNCTION test_func(float, OUT a bigint, OUT b bigint) 
RETURNS record AS 'select test_func1($1)[1],test_func1($1)[2]
'LANGUAGE SQL IMMUTABLE;

and 

CREATE OR REPLACE FUNCTION test_func1 (float)
RETURNS bigint[] AS '/home/math/skyindex/q3cube/operators/libxx.so', 
'test_func1' LANGUAGE C IMMUTABLE;


And I was surprised to see that in such case, when I call the function
test_func, the function test_func1 is called twice. Why actually the
optimizer do so ? It should not be very difficult to optimize it to one call,
isn't it ? 


With Best Regards,    Sergey

PS I tested this example with including in C code of test_func1 the static
counter of calls. 

*****************************************************
Sergey E. Koposov
Max-Planck Institut fuer Astronomie
Web: http://lnfm1.sai.msu.ru/~math 
E-mail: math@sai.msu.ru



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

Предыдущее
От: Christopher Kings-Lynne
Дата:
Сообщение: Re: Call for 7.5 feature completion
Следующее
От: Peter Eisentraut
Дата:
Сообщение: Re: Call for 7.5 feature completion