Re: Re: Patch to add functionality to specify ORDER BY in CREATE FUNCTION for SRFs

Поиск
Список
Период
Сортировка
От Jim Nasby
Тема Re: Re: Patch to add functionality to specify ORDER BY in CREATE FUNCTION for SRFs
Дата
Msg-id 54AAFB3F.9080509@BlueTreble.com
обсуждение исходный текст
Ответ на Re: Re: Patch to add functionality to specify ORDER BY in CREATE FUNCTION for SRFs  (Atri Sharma <atri.jiit@gmail.com>)
Ответы Re: Re: Patch to add functionality to specify ORDER BY in CREATE FUNCTION for SRFs  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
On 1/5/15, 12:20 PM, Atri Sharma wrote:
>     What would make sense to me is to teach the planner about inlining
>     SQL functions that include ORDER BY clauses, so that the performance
>     issue of a double sort could be avoided entirely transparently to
>     the user.
>
>
> It sounds good, but inlining in current way shall restrict the scope of optimization (which is not applicable for
currentdesign). For eg, you cannot inline RECORD returning SRFs...
 

Related... I'd like to see a way to inline a function that does something like:

CREATE FUNCTION foo(text) RETURNS int LANGUAGE sql AS $$
SELECT a FROM b WHERE lower(b.c) = lower($1)
$$

and have the performance be comparable to

SELECT ..., (SELECT a FROM b WHERE lower(b.c) = lower(something)) AS foo

I realize that there's a whole question about the function not being an SRF, but the thing is this works great when
manuallyinlined and is fast. The SQL function is significantly slower.
 
-- 
Jim Nasby, Data Architect, Blue Treble Consulting
Data in Trouble? Get it in Treble! http://BlueTreble.com



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

Предыдущее
От: Peter Eisentraut
Дата:
Сообщение: Re: SSL information view
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Re: Patch to add functionality to specify ORDER BY in CREATE FUNCTION for SRFs