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

2015-03-13 Thread Jeff Janes
On Mon, Jan 5, 2015 at 7:12 AM, Atri Sharma wrote: > > Hi All, > > Please forgive if this is a repost. > > Please find attached patch for supporting ORDER BY clause in CREATE > FUNCTION for SRFs. > Hi Atri, >From the discussion, I don't know if this patch is still being proposed. If so, it need

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

2015-01-06 Thread Michael Paquier
On Tue, Jan 6, 2015 at 12:12 AM, Atri Sharma wrote: > I will add the patch to current commitfest. It has been indeed added to the commit fest 2014-12. That's a bit late, moving it to upcoming one 2015-02. Thanks, -- Michael -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)

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

2015-01-06 Thread Ashutosh Bapat
Not in all cases postgres=# create function non_im_immutable_function() returns float as $$ begin return *random()*; end; $$ language plpgsql *immutable*; CREATE FUNCTION postgres=# select proname, provolatile from pg_proc where proname = 'random' or proname = 'non_im_immutable_function';

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

2015-01-06 Thread Amit Langote
On 07-01-2015 AM 08:33, Jim Nasby wrote: > On 1/6/15, 1:00 AM, Ashutosh Bapat 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 fun

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

2015-01-06 Thread Jim Nasby
On 1/6/15, 1:00 AM, Ashutosh Bapat 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. Actually, it

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

2015-01-06 Thread Amit Langote
On 06-01-2015 PM 04:26, Atri Sharma wrote: > On Tue, Jan 6, 2015 at 12:43 PM, Amit Langote > wrote: >> 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. >> >> > Personally, I

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

2015-01-05 Thread Atri Sharma
On Tue, Jan 6, 2015 at 12:43 PM, Amit Langote wrote: > On 06-01-2015 PM 04:08, Atri Sharma wrote: > > On Tue, Jan 6, 2015 at 12:29 PM, Amit Langote < > langote_amit...@lab.ntt.co.jp > > > I read what Ashutosh says as that a clause like IMMUTABLE does not > entail a node execution. Reading manual

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

2015-01-05 Thread Atri Sharma
On Tue, Jan 6, 2015 at 12:47 PM, Pavan Deolasee wrote: > > > On Tue, Jan 6, 2015 at 12:38 PM, Atri Sharma wrote: > >> >> > May be what Amit has in mind is that the planner can choose the most > optimal sorting algorithm using the hint that the dataset is probably > already sorted. Actually why n

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

2015-01-05 Thread Amit Langote
On 06-01-2015 PM 04:08, Atri Sharma wrote: > On Tue, Jan 6, 2015 at 12:29 PM, Amit Langote > 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 c

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

2015-01-05 Thread Pavan Deolasee
On Tue, Jan 6, 2015 at 12:38 PM, Atri Sharma wrote: > > > On Tue, Jan 6, 2015 at 12:29 PM, Amit Langote < > langote_amit...@lab.ntt.co.jp> wrote: > >> >> > >> >> Sounds something like ORDERED BY x implying output is "known" ordered by >> x perhaps enough hint for the planner to make necessary pla

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

2015-01-05 Thread Atri Sharma
On Tue, Jan 6, 2015 at 12:30 PM, Ashutosh Bapat < ashutosh.ba...@enterprisedb.com> wrote: > > > On Tue, Jan 6, 2015 at 12:23 PM, Atri Sharma 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 elimin

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

2015-01-05 Thread Atri Sharma
On Tue, Jan 6, 2015 at 12:29 PM, Amit Langote wrote: > On 06-01-2015 PM 04:00, Ashutosh Bapat wrote: > > On Tue, Jan 6, 2015 at 12:23 PM, Atri Sharma > wrote: > >>> We can eliminate the new node and put onus or having the right order on > >>> the user like we do with volatile setting of the func

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

2015-01-05 Thread Amit Langote
On 06-01-2015 PM 04:00, Ashutosh Bapat wrote: > On Tue, Jan 6, 2015 at 12:23 PM, Atri Sharma wrote: >>> We can eliminate the new node and put onus or having the right order on >>> the user like we do with volatile setting of the function. >>> >>> >> >> That is exactly what the new node does, since

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

2015-01-05 Thread Ashutosh Bapat
On Tue, Jan 6, 2015 at 12:23 PM, Atri Sharma wrote: > >>> >>> The overhead of this patch is small. A new path is added for the >>> preorder keys, and OrderCheck node's additional cost is pretty low, given >>> that it only compares two rows and stores only a single row (previous row >>> seen), hen

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

2015-01-05 Thread Atri Sharma
> > >> >> The overhead of this patch is small. A new path is added for the preorder >> keys, and OrderCheck node's additional cost is pretty low, given that it >> only compares two rows and stores only a single row (previous row seen), >> hence the memory footprint is minuscule. >> >> > We can elim

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

2015-01-05 Thread Ashutosh Bapat
On Mon, Jan 5, 2015 at 8:42 PM, Atri Sharma wrote: > > Hi All, > > Please forgive if this is a repost. > > Please find attached patch for supporting ORDER BY clause in CREATE > FUNCTION for SRFs. Specifically: > > CREATE OR REPLACE FUNCTION func1(OUT e int, OUT f int) returns setof > record as '

[HACKERS] Patch to add functionality to specify ORDER BY in CREATE FUNCTION for SRFs

2015-01-05 Thread Atri Sharma
Hi All, Please forgive if this is a repost. Please find attached patch for supporting ORDER BY clause in CREATE FUNCTION for SRFs. Specifically: CREATE OR REPLACE FUNCTION func1(OUT e int, OUT f int) returns setof record as ' SELECT a,b FROM table1 ORDER BY a; ' language 'sql' ORDER BY e; This