David G Johnston <david.g.johnston@gmail.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