From: | Gerald Britton <gerald(dot)britton(at)gmail(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>, pgsql-general(at)lists(dot)postgresql(dot)org |
Subject: | Re: Are PostgreSQL functions that return sets or tables evaluated lazily or eagerly? |
Date: | 2020-01-19 20:08:35 |
Message-ID: | CAPxRSnayixFeoK=ON56dE2BFiBe0SykKH4ntffGEHJAu0QRtpw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Love to see "return next" work like python yield! Anyone working on that?
On Sun, Jan 5, 2020, 5:46 PM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Gerald Britton <gerald(dot)britton(at)gmail(dot)com> writes:
> > Back to where I started in my top post: I became interested in this due
> to
> > the doc note on returning a cursor and that it can be an efficient way to
> > handle large result sets. I suppose that implies lazy evaluation. Does
> > that mean that if I need plpgsql for a function for he language's power
> yet
> > want the results to be returned lazily, a cursor is the (only?) way to
> go?
>
> Nope. The docs' reference to a cursor only suggests that if you can
> express the function's result as a single SQL query, then opening a
> cursor for that query and returning the cursor name will work. But
> if you need plpgsql to express the computation, that's not a terribly
> helpful suggestion.
>
> If you'd like to see some actual movement on the missing feature about
> lazy evaluation in FROM, you could help test/review the pending patch
> about it:
>
> https://commitfest.postgresql.org/26/2372/
>
> However, that still is only half of the problem, because you also need
> a PL that is prepared to cooperate, which I don't believe plpgsql is.
> I think (might be wrong) that a plpython function using "yield" can
> be made to compute its results lazily.
>
> regards, tom lane
>
From | Date | Subject | |
---|---|---|---|
Next Message | Ramesh Penuballi | 2020-01-20 06:00:04 | Re: postgresql commands(psql,createdb,dropdb) are not working from shell script |
Previous Message | George Neuner | 2020-01-19 19:45:23 | testing post through gmane.io |