pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Pavel Stehule <pavel.stehule@gmail.com>
Cc: martin.langwisch@gmx.net, "pgsql-bugs@postgresql.org" <pgsql-bugs@postgresql.org>
Subject: Re: BUG #14525: select <function>.* takes extremely long time
Date: Thu, 02 Feb 2017 09:27:32 -0500
Message-ID: <32417.1486045652@sss.pgh.pa.us> (raw)
In-Reply-To: <CAFj8pRAVLxT+bk8iTZN7E5yTG+3p+rVGpWBwcRwzcokTXjDc0A@mail.gmail.com>
References: <20170202090519.1411.68788@wrigleys.postgresql.org>
	<CAFj8pRAVLxT+bk8iTZN7E5yTG+3p+rVGpWBwcRwzcokTXjDc0A@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-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



view thread (3+ messages)

Message-ID: <32417.1486045652@sss.pgh.pa.us>
Permalink:  ../32417.1486045652@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/32417.1486045652@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, pavel.stehule@gmail.com
  Subject: Re: BUG #14525: select <function>.* takes extremely long time
  In-Reply-To: <32417.1486045652@sss.pgh.pa.us>
  References: <20170202090519.1411.68788@wrigleys.postgresql.org> <CAFj8pRAVLxT+bk8iTZN7E5yTG+3p+rVGpWBwcRwzcokTXjDc0A@mail.gmail.com> <32417.1486045652@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox