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

From Amit Langote
Subject Re: Patch to add functionality to specify ORDER BY in CREATE FUNCTION for SRFs
Date
Msg-id 54AB8B35.6080903@lab.ntt.co.jp
Whole thread Raw
In response to Re: Patch to add functionality to specify ORDER BY in CREATE FUNCTION for SRFs  (Atri Sharma <atri.jiit@gmail.com>)
Responses Re: Patch to add functionality to specify ORDER BY in CREATE FUNCTION for SRFs
List pgsql-hackers
On 06-01-2015 PM 04:08, Atri Sharma wrote:
> On Tue, Jan 6, 2015 at 12:29 PM, Amit Langote <Langote_Amit_f8@lab.ntt.co.jp
>> wrote:
>>> Even checking whether the output of the function is in the right order or
>>> not, has its cost. I am suggesting that we can eliminate this cost as
>> well.
>>> For example, PostgreSQL does not check whether a function is really
>>> immutable or not.
>>>
>>
>> Sounds something like ORDERED BY x implying output is "known" ordered by
>> x perhaps enough hint for the planner to make necessary plan choices
>> though I may be wrong.
>>
>>
>>
> I may be missing something, but isnt what you mentioned the exact
> functionality this patch adds?
> 

I read what Ashutosh says as that a clause like IMMUTABLE does not
entail a node execution. Reading manual for CREATE FUNCTION:

<manual>
IMMUTABLE
STABLE
VOLATILE

These attributes inform the query optimizer about the behavior of the
function.
</manual>

They declare the shape of the kind of output the function produces and
planner simply trusts the declaration meaning it does not add a node to
check if, say, an IMMUTABLE function did not actually modify the
database or that it is returning the same output for a given input.

Though, I have no strong opinion on whether one thing is good or the
other or whether they cover some particular use case all the same.
Perhaps you can say that better.

Thanks,
Amit




pgsql-hackers by date:

Previous
From: Pavan Deolasee
Date:
Subject: Re: Patch to add functionality to specify ORDER BY in CREATE FUNCTION for SRFs
Next
From: Atri Sharma
Date:
Subject: Re: Patch to add functionality to specify ORDER BY in CREATE FUNCTION for SRFs