Jeff Davis <pgsql@j-davis.com> writes:
> From the docs on plperl:
> "Usually you'll want to return rows one at a time, both to speed up
> startup time and to keep from queueing up the entire result set in
> memory. You can do this with return_next as illustrated below."
> Am I misunderstanding the docs? How do I just return one tuple at a time
> without PostgreSQL continuing the loop?
The docs are perhaps a little misleading. The perl function will
execute to completion in any case --- it's hard to see how to prevent
that from happening without breaking perl. The point of the comment
is that with return_next, buffering of the result set happens in a
TupleStore object (which knows how to spill an oversize set to disk)
rather than inside perl (which doesn't).
regards, tom lane