I have a function f that returns a composite type. The following query: select f().* takes about ten times as long as either select f() or select (f).* from (select f() as f) a;
It doesn't matter whether the function returns a composite type or a set of composite type.
This behaviour strikes me as odd, to say the least and it took me quite some time to find out why my code was so slow.
Although it looks strange - it is expected behave - and it is not a bug
XT is a composite type (a, b, c)
fx is a function with XT result.
SELECT (fx()).* is translated by parser to query SELECT fx().a, fx().b, fx().c ....
When your function fx is slow, then you cannot to use a (fx()).* pattern