Re: [GENERAL] Returning a RECORD, not SETOF RECORD

Поиск
Список
Период
Сортировка
От Michael Fuhr
Тема Re: [GENERAL] Returning a RECORD, not SETOF RECORD
Дата
Msg-id 20050429172135.GA2695@winnie.fuhr.org
обсуждение исходный текст
Ответ на Re: [GENERAL] Returning a RECORD, not SETOF RECORD  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: [GENERAL] Returning a RECORD, not SETOF RECORD  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
On Fri, Apr 29, 2005 at 10:36:05AM -0400, Tom Lane wrote:
>
> regression=# select (xyz(unique1,unique2)).* from tenk1 limit 5;

This is a little off topic, but I've noticed that the above invokes
the function once per output column:

CREATE FUNCTION xyz(INOUT x integer, INOUT y integer, OUT z integer) AS $$
BEGIN   RAISE INFO 'calling xyz';   z := x + y;
END;
$$ LANGUAGE plpgsql IMMUTABLE;

SELECT xyz(1,2);
INFO:  calling xyz  xyz   
---------(1,2,3)
(1 row)

SELECT (xyz(1,2)).*;
INFO:  calling xyz
INFO:  calling xyz
INFO:  calling xyzx | y | z 
---+---+---1 | 2 | 3
(1 row)

Is that because the splat causes the query to be expanded into
"SELECT (xyz(1,2)).x, (xyz(1,2)).y, (xyz(1,2)).z"?  Is it possible
or desirable to optimize that into a single call, at least if the
function were stable or immutable?

-- 
Michael Fuhr
http://www.fuhr.org/~mfuhr/


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

Предыдущее
От: "Marc G. Fournier"
Дата:
Сообщение: Re: Feature freeze date for 8.1
Следующее
От: Tom Lane
Дата:
Сообщение: Re: [GENERAL] Returning a RECORD, not SETOF RECORD