Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!news-1.dfn.de!news.dfn.de!news.informatik.hu-berlin.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Robert Klemme Newsgroups: comp.databases.postgresql Subject: Re: Returning a table in SQL Date: Thu, 28 Aug 2014 21:45:07 +0200 Lines: 33 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net E7AScufChfegt94vAbN7kAfzDgBpnfubYvcHI8Y2iSSOhieKk= Cancel-Lock: sha1:qyNr6OU7ogH8JpcQ0iCuy5Krzgk= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.0 In-Reply-To: Xref: csiph.com comp.databases.postgresql:597 On 28.08.2014 17:51, Harry Tuttle wrote: > AP wrote on 27.08.2014 22:37: >> Actually, I figured it out : >> >> with report as (select >> some_report('Customer','2014-08-01','2014-08-08') cr) >> select >> (cr).field1, >> (cr).field2, >> (cr).field3 >> from report; >> >> gives three separated columns. >> >> WITH clause is for clarity solely No, in PostgreSQL it is an optimization fence that actually influences optimizer's behavior. Apart from that I don't see the improvement in clarity caused by the additional layer. > It's still "wrong". > > You should really put the function into the from clause. s/should/must/ > select * > from some_report('Customer','2014-08-01','2014-08-08') Kind regards robert