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