Re: Re: Patch to add functionality to specify ORDER BY in CREATE FUNCTION for SRFs

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: David G Johnston <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org, Atri Sharma <atri(dot)jiit(at)gmail(dot)com>
Subject: Re: Re: Patch to add functionality to specify ORDER BY in CREATE FUNCTION for SRFs
Date: 2015-01-05 17:54:41
Message-ID: 1330.1420480481@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

David G Johnston <david(dot)g(dot)johnston(at)gmail(dot)com> writes:
> Atri Sharma wrote
>> If order of result rows is not the same as required, an error is raised:
>>
>> SELECT * FROM incorrect_order_nulls() ORDER BY e NULLS LAST;
>> ERROR: Order not same as specified

> First reaction for the error was unfavorable but (see below) it likely is
> the best option and does adequately cover the reason for failure -
> programmer error.

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.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Josh Berkus 2015-01-05 17:59:34 Re: Redesigning checkpoint_segments
Previous Message Peter Geoghegan 2015-01-05 17:54:02 INSERT ... ON CONFLICT UPDATE and RLS