Re: Recursive calls to functions that return sets
От | Alvaro Herrera |
---|---|
Тема | Re: Recursive calls to functions that return sets |
Дата | |
Msg-id | 20060322173454.GA7100@surnet.cl обсуждение исходный текст |
Ответ на | Re: Recursive calls to functions that return sets (Thomas Hallgren <thomas@tada.se>) |
Список | pgsql-hackers |
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
В списке pgsql-hackers по дате отправления: