Re: return next - Mailing list pgsql-general

From Tom Lane
Subject Re: return next
Date
Msg-id 18533.1131721036@sss.pgh.pa.us
Whole thread Raw
In response to return next  (Jeff Davis <pgsql@j-davis.com>)
List pgsql-general
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

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Best way to use indexes for partial match at
Next
From: Andrew Schmidt
Date:
Subject: Re: Two slightly different queries produce same results,