Thomas Hallgren wrote:
> Recursive calls works in PL/Java. No problem there. But the larger the 
> set, the more memory it consumes. Do I read your answers correctly if I 
> conclude this is a known limitation when SPI is used? I.e. there's no 
> way to stream one row at a time without ever building the full set?

Hmm, are you using a tuplestore?  The PL/php code for return_next looks
like this:

ZEND_FUNCTION(return_next)
{
    ... some stuff ...

    /* Use the per-query context so that the tuplestore survives */
    oldcxt = MemoryContextSwitchTo(rsi->econtext->ecxt_per_query_memory);

    /* Form the tuple */
    tup = plphp_srf_htup_from_zval(param, current_attinmeta, current_memcxt);

    /* First call?  Create the tuplestore. */
    if (!current_tuplestore)
        current_tuplestore = tuplestore_begin_heap(true, false, work_mem);

    /* Save the tuple and clean up */
    tuplestore_puttuple(current_tuplestore, tup);
    heap_freetuple(tup);

    MemoryContextSwitchTo(oldcxt);
}

-- 
Alvaro Herrera                                http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

               http://www.postgresql.org/docs/faq

Reply via email to