pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Milen Kulev <makulev@gmx.net>
To: 'Talha Khan' <talha.amjad@gmail.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: Pipelined functions in Postgres
Date: Tue, 19 Sep 2006 23:29:07 +0200
Message-ID: <008b01c6dc32$a35c5290$0a00a8c0@trivadis.com> (raw)
In-Reply-To: <f80885fc0609191407p496ac28dy5825698e7b5065d0@mail.gmail.com>

Talha, 
do you know how much memory is consumed by the SETOF function ?
What happens with memory consumption of the function if 
SELECT ename FROM emp WHERE sal > $1
 returns 10 mio rows ? 
I suppose that memory for the RECORD structure is immediately reused by the next record.
 
Regards, Milen 
  

-----Original Message-----
From: Talha Khan [mailto:talha.amjad@gmail.com] 
Sent: Tuesday, September 19, 2006 11:08 PM
To: Milen Kulev
Cc: pgsql-performance@postgresql.org
Subject: Re: [PERFORM] Pipelined functions in Postgres


Hi Milen,
 
Pipelined function is a code that acts like a database table.
 
Inorder to use this functionality in postgres you would need to write the function like this
 
CREATE OR REPLACE FUNCTION get_test_data (numeric)
    RETURNS SETOF RECORD AS
$$
DECLARE
    temp_rec    RECORD;
BEGIN
    FOR temp_rec IN (SELECT ename FROM emp WHERE sal > $1)
    LOOP
        RETURN NEXT temp_rec;
    END LOOP;
    RETURN;
END;
$$ LANGUAGE plpgsql;
 
now inorder to call this function you would write the code as follows
 
SELECT * FROM get_test_data(1000) AS t1 (emp_name VARCHAR);
 
 
Regards
Talha Amjad


 
On 9/19/06, Milen Kulev <makulev@gmx.net> wrote: 

Hello Lister,
I am curios whether I can emulate the Oracle pipelined functions functionality in PG too (using RETURN NEXT ). For more 
information and examples about Oracle pipelined functions see:
http://asktom.oracle.com/pls/ask/f?p=4950:8:8127757633768425921::NO::F4950_P8_DISPLAYID,F4950_P8_CRI...
<http://asktom.oracle.com/pls/ask/f?p=4950:8:8127757633768425921::NO::F4950_P8_DISPLAYID,F4950_P8_CRI...
> 

I have used  pipeline functions in DWH enviromnent  with success and would like
To use similar concept in PG too.

Any help, examples , links and  shared experiences would be greately appreciated.

Best Regards.
Milen


---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
      subscribe-nomail command to majordomo@postgresql.org so that your
      message can get through to the mailing list cleanly

view thread (7+ messages)  latest in thread

Message-ID: <008b01c6dc32$a35c5290$0a00a8c0@trivadis.com>
Permalink:  ../008b01c6dc32$a35c5290$0a00a8c0@trivadis.com/
Also on:    postgresql.org/message-id/008b01c6dc32$a35c5290$0a00a8c0@trivadis.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: makulev@gmx.net, talha.amjad@gmail.com
  Subject: Re: Pipelined functions in Postgres
  In-Reply-To: <008b01c6dc32$a35c5290$0a00a8c0@trivadis.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox