Re: Re: Patch to add functionality to specify ORDER BY in CREATE FUNCTION for SRFs - Mailing list pgsql-hackers

From Robert Haas
Subject Re: Re: Patch to add functionality to specify ORDER BY in CREATE FUNCTION for SRFs
Date
Msg-id CA+TgmoZGbexC4=Nt6Ovw_RpGPMB6N5v7Lk3HnGa90aSaS0Fpsg@mail.gmail.com
Whole thread Raw
In response to Re: Re: Patch to add functionality to specify ORDER BY in CREATE FUNCTION for SRFs  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On Mon, Jan 5, 2015 at 12:54 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> TBH, my first reaction to this entire patch is unfavorable: it's a
> solution in search of a problem.  It adds substantial complication not
> only for users but for PG developers in order to solve a rather narrow
> performance issue.
>
> What would make sense to me is to teach the planner about inlining
> SQL functions that include ORDER BY clauses, so that the performance
> issue of a double sort could be avoided entirely transparently to
> the user.

That's not a bad idea, but it only helps for SQL functions.  Actually,
the problem I have run into in the past was not that the planner
didn't know the ordering of the SRF's return value, but that it had no
statistics for it, and therefore made bad optimization decisions.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



pgsql-hackers by date:

Previous
From: Sawada Masahiko
Date:
Subject: Re: Merging postgresql.conf and postgresql.auto.conf
Next
From: Robert Haas
Date:
Subject: Re: Compression of full-page-writes