Re: V3 protocol vs INSERT/UPDATE RETURNING

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Jonah H(dot) Harris" <jonah(dot)harris(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: V3 protocol vs INSERT/UPDATE RETURNING
Date: 2006-08-11 20:14:06
Message-ID: 23253.1155327246@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

"Jonah H. Harris" <jonah(dot)harris(at)gmail(dot)com> writes:
> On 8/11/06, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> 4. Treat PORTAL_ONE_RETURNING like PORTAL_UTIL_SELECT rather than
>> like PORTAL_ONE_SELECT; that is, execute the query to completion
>> on first call and stash the results in a tuplestore until the
>> client fetches them.

> I agree that it's inefficient, but am trying to think of any other
> positive reasons for doing #4 instead.

I found a showstopper reason why it has to be done this way: the AFTER
TRIGGER code isn't capable of dealing with interleaved execution of
different queries (it can basically only track nested queries).
Possibly that could be improved in the future, but for 8.2 I think
we're stuck with using a tuplestore.

One optimization I think might not be too hard is to bypass the
tuplestore and stream RETURNING tuples directly to the client if the
first Execute for the portal doesn't give a row limit (which is surely
the typical case). I don't plan to do that in the first cut though.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2006-08-11 20:15:16 pgsql: Allow commenting of variables in postgresql.conf to restore them
Previous Message Bruce Momjian 2006-08-11 19:42:35 pgsql: plperl: Allow conversion from perl to postgresql array in OUT