Re: [BUGS] BUG #14525: select .* takes extremely long time - Mailing list pgsql-bugs

From Tom Lane
Subject Re: [BUGS] BUG #14525: select .* takes extremely long time
Date
Msg-id 32417.1486045652@sss.pgh.pa.us
Whole thread Raw
In response to Re: [BUGS] BUG #14525: select .* takes extremely long time  (Pavel Stehule <pavel.stehule@gmail.com>)
List pgsql-bugs
Pavel Stehule <pavel.stehule@gmail.com> writes:
> 2017-02-02 10:05 GMT+01:00 <martin.langwisch@gmx.net>:
>> 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;

> 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

Yeah.  Putting the function in FROM is the recommended fix.  You can
simplify the pattern to

    select f.* from f() as f

or if the function needs arguments from a table,

    select f.* from tab, lateral f(x,y) as f

            regards, tom lane


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

pgsql-bugs by date:

Previous
From: tiago.babo@gmail.com
Date:
Subject: [BUGS] BUG #14526: no unique or exclusion constraint matching the ON CONFLICT
Next
From: bricklen
Date:
Subject: Re: [BUGS] Bug in postgres log file