Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cZIMQ-0001W1-GB for pgsql-bugs@arkaria.postgresql.org; Thu, 02 Feb 2017 14:27:42 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cZIMQ-0006io-37 for pgsql-bugs@arkaria.postgresql.org; Thu, 02 Feb 2017 14:27:42 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cZIMP-0006ih-M4 for pgsql-bugs@postgresql.org; Thu, 02 Feb 2017 14:27:41 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cZIMN-0005xc-4x for pgsql-bugs@postgresql.org; Thu, 02 Feb 2017 14:27:41 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id v12ERWrC032418; Thu, 2 Feb 2017 09:27:32 -0500 From: Tom Lane To: Pavel Stehule cc: martin.langwisch@gmx.net, "pgsql-bugs@postgresql.org" Subject: Re: BUG #14525: select .* takes extremely long time In-reply-to: References: <20170202090519.1411.68788@wrigleys.postgresql.org> Comments: In-reply-to Pavel Stehule message dated "Thu, 02 Feb 2017 13:13:10 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <32416.1486045652.1@sss.pgh.pa.us> Date: Thu, 02 Feb 2017 09:27:32 -0500 Message-ID: <32417.1486045652@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org Pavel Stehule writes: > 2017-02-02 10:05 GMT+01:00 : >> 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