Skip site navigation (1) Skip section navigation (2)

Re: [HACKERS] PL/Perl list value return causes segfault

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: David Fetter <david(at)fetter(dot)org>
Cc: PostgreSQL Patches <pgsql-patches(at)postgresql(dot)org>,PostgreSQL Docs <pgsql-docs(at)postgresql(dot)org>,Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>,Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>,Michael Fuhr <mike(at)fuhr(dot)org>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: [HACKERS] PL/Perl list value return causes segfault
Date: 2005-07-30 13:47:58
Message-ID: 42EB850E.9080205@dunslane.net (view raw or flat)
Thread:
Lists: pgsql-docspgsql-hackerspgsql-patches

David Fetter wrote:

>*** 716,724 ****
>  
>      <listitem>
>       <para>
>!       In the current implementation, if you are fetching or returning
>!       very large data sets, you should be aware that these will all go
>!       into memory.
>       </para>
>      </listitem>
>     </itemizedlist>
>--- 766,776 ----
>  
>      <listitem>
>       <para>
>!       If you are fetching or returning very large data sets using
>!       <literal>spi_exec_query</literal>, you should be aware that
>!       these will all go into memory.  You can avoid this by using
>!       <literal>spi_query</literal>/<literal>spi_fetchrow</literal> as
>!       illustrated earlier.
>       </para>
>      </listitem>
>     </itemizedlist>
>  
>
>  
>

You have rolled 2 problems into one - spi_query+spi_fetchrow does not 
address the issue of returning large data sets.

Suggest instead:

<para>

       If you are fetching very large data sets using
       <literal>spi_exec_query</literal>, you should be aware that
       these will all go into memory.  You can avoid this by using
       <literal>spi_query</literal> and <literal>spi_fetchrow</literal> 
	as illustrated earlier.
</para>
<para>
	A similar problem occurs if a set-returning function passes 
	a large set of rows back to postgres via 
	<literal>return</literal>. You can avoid this 
	problem too by instead using <literal>return_next</literal> for 
	each row returned, as shown previously.
</para>




cheers

andrew

In response to

Responses

pgsql-docs by date

Next:From: David FetterDate: 2005-07-31 00:34:58
Subject: Re: [HACKERS] PL/Perl list value return causes segfault
Previous:From: David FetterDate: 2005-07-30 05:43:54
Subject: Re: [HACKERS] PL/Perl list value return causes segfault

pgsql-hackers by date

Next:From: Bruce MomjianDate: 2005-07-30 14:16:09
Subject: Re: [HACKERS] Win32 build broken by recent changes to xlog.c
Previous:From: Magnus HaganderDate: 2005-07-30 13:47:33
Subject: Win32 build broken by recent changes to xlog.c

pgsql-patches by date

Next:From: Bruce MomjianDate: 2005-07-30 14:16:09
Subject: Re: [HACKERS] Win32 build broken by recent changes to xlog.c
Previous:From: Magnus HaganderDate: 2005-07-30 13:47:33
Subject: Win32 build broken by recent changes to xlog.c

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group